大家好我现在正在构建我的游戏并试图在几秒钟后让一些文本消失。我正在使用Phaser而我不确定如何做到这一点。
目前我有:
Asteroid.time.events.remove(Phaser.Timer.SECOND - 3, this.startInstructions3, this);
我的文字显示在页面上:
if (!this.rockmodel.countLiving()) {
Asteroid.time.events.add(Phaser.Timer.SECOND * 3, this.levelIncrease, this);
var startInstructions3 = 'NEXT LEVEL! ';
this.gametext3 = Asteroid.add.text(Asteroid.world.centerX, Asteroid.world.centerY, startInstructions3, lifefont3.thefont3);
this.gametext3.align = 'center';
this.gametext3.anchor.set(0.5, 0.5);
}
然后,当我回到我的levelIncrease
功能时,我有:
if (this.rockcount < rocksincoming.max) {
this.rockcount += rocksincoming.astup;
}
Asteroid.time.events.remove(Phaser.Timer.SECOND * 3, this.startInstructions3, this);
this.randomrock();
},
endofgame: function () {
Asteroid.state.start(gameobjectstouse.menu);
},
我的问题是,它是否像-3或者你可以在Phaser中做一些固定的东西,比如持续时间或类似的东西?我似乎无法找到任何相关信息。
感谢。
答案 0 :(得分:1)
实际上an official example涵盖了这种情况。
您的Asteroid.time.events.remove()
实际上会删除一个事件,而不会添加删除事件。例如,如果您有一个循环并希望删除该事件的事件,则可以使用time.events.remove
。
因此,您希望添加一个在三秒后触发的事件,如下所示,而不是Asteroid.time.events.remove
行:
Asteroid.time.events.add(Phaser.Timer.SECOND - 3, this.nameOfFunctionToHideText, this);
nameOfFunctionToHideText
(或您创建的任何新功能)将删除文本。