如何让文本在几秒钟后消失
how to get text to disappear after few seconds
大家好,我现在正在构建我的游戏,并试图让一些文本在几秒钟后消失。我正在使用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的持续时间或类似的东西?我似乎找不到任何关于它的信息。
谢谢。
实际上有一个官方示例为您介绍了这个场景。
Asteroid.time.events.remove()
实际上会删除一个事件,而不是添加一个删除事件。例如,如果您有一个循环的事件,并且希望删除该事件,则可以使用time.events.remove
。
因此,您希望添加一个在三秒后触发的事件,因此类似于以下内容,而不是您的Asteroid.time.events.remove
行:
Asteroid.time.events.add(Phaser.Timer.SECOND - 3, this.nameOfFunctionToHideText, this);
其中nameOfFunctionToHideText
(或您创建的任何新函数)将是删除文本的函数。
相关文章:
- 如何让文本在几秒钟后消失
- angularJS,一个部分或模态通知,加载几秒钟后就会消失
- 淡入淡出每隔几秒就会发生变化的图像
- Javascript在秒消失时显示DIV元素,并在此之后隐藏栏的选项
- Jquery 动画在单击几次后消失
- 闪烁文本几秒钟 - 然后消失
- 在画布上显示字符串仅显示几分之一秒
- Google+ 交互式帖子弹出窗口在 0,5 秒后消失
- 输入栏在几个塞昆德后消失
- 每隔x秒重复几次触发器('click')功能
- 重新加载几次后,时间和日期消失
- HTML5 -视频播放时每隔几秒触发一次事件
- 使用JavaScript在视频结束前几秒运行一个函数
- 如何实现几秒钟后消失的简单确认消息
- 使用setTimeout在X秒后隐藏几个元素
- Div内容在出现几毫秒后消失
- 反应-每隔几秒渲染相对时间
- 显示前的几秒延迟:无
- 使用socket.io每隔几秒以编程方式触发一个事件
- 在每隔几秒播放的动画中添加声音