gpt4 book ai didi

javascript - 未捕获的类型错误 : Cannot read property 'add' of null phaser

转载 作者:行者123 更新时间:2023-11-28 06:33:28 25 4
gpt4 key购买 nike

下面是菜单所在的代码的简化版本。我不断收到此错误。当我单击播放按钮时会发生此错误:

Uncaught TypeError: Cannot read property 'add' of null

我知道那是当我检查 Sprite 播放是否被点击但无法找出问题时。

这是图片: enter image description here

JsFiddle Format

  preload: function() {
game.load.image('background', 'http://s1.postimg.org/nqynk9tkv/starfield.png')
game.load.image('play-back', 'http://icon-park.com/imagefiles/movie_play_black.png');

},
create: function() {
this.backgroundImg = this.game.add.tileSprite(0, 0, 500, 550, 'background')

this.gameText = game.add.text(game.world.centerX-190, game.world.centerY - 150, "Space Invaders", {
font: "60px Times New Roman",
fill: "#ccccb3",
fontWeight: "bold",
stroke: "white",
strokeThickness: 2.5
});

/* // this.gameText.anchor.setTo(0.5)
this.gameText.angle =
*/
play = game.add.sprite(120,280,'play-back')
play.scale.setTo(0.5);
game.physics.arcade.enable(play);
play.events.onInputDown.add(this.start, this);

},
update: function() {
this.backgroundImg.tilePosition.y += 5;


},
render: function() {

},
start: function() {

game.start.main('main')
}

};

最佳答案

关于javascript - 未捕获的类型错误 : Cannot read property 'add' of null phaser,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34493190/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com