我有一个精灵'Bomb'当玩家触摸它时'Bomb'将在3秒后爆炸,时间将显示为动画或补间。这将是非常高兴给出示例代码。
答案 0 :(得分:2)
你有什么尝试?任何示例代码?也许是这样的?
bombsprite = game.add.sprite(100, 100, 'mybomb');
// scale the bomb big/small 3 times (=3 seconds)
var bombtween = this.game.add.tween(bombsprite.scale).to({x: 1.1, y: 1.1}, 500, Phaser.Easing.Quadratic.InOut)
.to({x: 1.0, y: 1.0}, 500, Phaser.Easing.Quadratic.InOut)
.to({x: 1.1, y: 1.1}, 500, Phaser.Easing.Quadratic.InOut)
.to({x: 1.0, y: 1.0}, 500, Phaser.Easing.Quadratic.InOut)
.to({x: 1.1, y: 1.1}, 500, Phaser.Easing.Quadratic.InOut)
.to({x: 1.0, y: 1.0}, 500, Phaser.Easing.Quadratic.InOut);
// after 3 times scale effect call explode function
bombtween.onComplete.add(doBombExplode);
bombtween.start();
function doBombExplode(scaleobj, tween) {
// do something
}
答案 1 :(得分:0)
if(/*if timer is not finished){
bomb_timer = game.time.events.add(Phaser.Timer.SECOND / 2, set_time, this);
}
function set_time() {
time_left -= .5;
}
如果正确实施,将如下所示:3,2.5,2,1.5,1,0.5,0。