function dieCrushed() {
console.log('crused');
var txt = this.add.text(x, y, 'GAME OVER');
}
错误:无法读取未定义的属性“ destroy”
当我在phaser3中触发此功能时,我想在屏幕上写一个文本
答案 0 :(得分:0)
var config = {
type: Phaser.AUTO,
parent: 'phaser-example',
loader: {
baseURL: 'https://raw.githubusercontent.com/nazimboudeffa/assets/master/',
crossOrigin: 'anonymous'
},
width: 800,
height: 600,
physics: {
default: 'arcade'
},
scene: {
preload: preload,
create: create
}
};
var game = new Phaser.Game(config);
function preload()
{
this.load.image('dude', 'sprites/phaser-dude.png')
}
function create ()
{
var txt = this.add.text(50, 50, '');
this.input.on('pointerdown', function(){
txt.setText('GAME OVER')
})
}
<script src="//cdn.jsdelivr.net/npm/phaser@3.17.0/dist/phaser.min.js"></script>