numbers fly everywhere
This commit is contained in:
parent
586864c9e3
commit
daeda4aa59
34
src/game.js
34
src/game.js
@ -74,6 +74,29 @@ game.state.add('play', {
|
|||||||
strokeThickness: 4
|
strokeThickness: 4
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// DMG POOL
|
||||||
|
this.dmgTextPool = this.add.group()
|
||||||
|
var dmgText;
|
||||||
|
for(var d=0;d<50;d++){
|
||||||
|
dmgText = this.add.text(0,1, '1', {
|
||||||
|
font: '64px Arial Black',
|
||||||
|
fill: '#fff',
|
||||||
|
strokeThickness: 4
|
||||||
|
});
|
||||||
|
dmgText.exists = false;
|
||||||
|
dmgText.tween = game.add.tween(dmgText).to({
|
||||||
|
alpha: 0,
|
||||||
|
y: 100,
|
||||||
|
x: this.game.rnd.integerInRange(100,700)
|
||||||
|
}, 1000, Phaser.Easing.Cubic.Out);
|
||||||
|
|
||||||
|
dmgText.tween.onComplete.add(function(text, tween){
|
||||||
|
text.kill();
|
||||||
|
});
|
||||||
|
this.dmgTextPool.add(dmgText);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
render: function(){
|
render: function(){
|
||||||
game.debug.text(
|
game.debug.text(
|
||||||
@ -82,10 +105,19 @@ game.state.add('play', {
|
|||||||
this.game.world.centerY - this.currentAlien.height / 2);
|
this.game.world.centerY - this.currentAlien.height / 2);
|
||||||
|
|
||||||
},
|
},
|
||||||
onClickAlien: function(){
|
onClickAlien: function(alien, pointer){
|
||||||
|
|
||||||
this.currentAlien.damage(this.player.clickDmg);
|
this.currentAlien.damage(this.player.clickDmg);
|
||||||
this.alienHealthText.text = this.currentAlien.alive ? this.currentAlien.health + " HP" : "DEAD";
|
this.alienHealthText.text = this.currentAlien.alive ? this.currentAlien.health + " HP" : "DEAD";
|
||||||
|
|
||||||
|
var dmgText = this.dmgTextPool.getFirstExists(false);
|
||||||
|
if (dmgText){
|
||||||
|
dmgText.text = this.player.clickDmg;
|
||||||
|
dmgText.reset(pointer.positionDown.x, pointer.positionDown.y);
|
||||||
|
dmgText.alpha = 1;
|
||||||
|
dmgText.tween.start();
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
onKilledAlien: function(alien){
|
onKilledAlien: function(alien){
|
||||||
alien.position.set(1000, this.game.world.centerY);
|
alien.position.set(1000, this.game.world.centerY);
|
||||||
|
Loading…
Reference in New Issue
Block a user