Word bubbles

This commit is contained in:
2014-06-11 23:53:49 -07:00
parent beaa3cd7c6
commit 5fe4604409

View File

@@ -353,12 +353,7 @@ var AISprite = function(game, x, y, spritetype) {
this.bubble_style = {font: '12px Arial Bold', fill: '#ffffff', align: 'center'}
this.bubble = game.add.text(this.x, this.y - 20, this.bubble_text, this.bubble_style);
function destroybubble() {
this.bubble.destroy();
this.bubble = null;
}
setTimeout(destroybubble, 20000);
setTimeout(function(){this.clear_bubble = true;}, 20000);
}
this.update = function()
@@ -376,8 +371,13 @@ var AISprite = function(game, x, y, spritetype) {
if ( this.bubble !== null ) {
this.bubble.destroy();
if ( this.clear_bubble == true ) {
this.bubble = null;
this.clear_bubble = false;
} else {
this.bubble = game.add.text(this.x, this.y - 20, this.bubble_text, this.bubble_style);
}
}
switch ( game.rnd.integerInRange(0, 4) ) {
case 0: {
@@ -411,6 +411,8 @@ var AISprite = function(game, x, y, spritetype) {
'townsfolk-guard-2'
];
this.bubble = null;
this.clear_bubble = false;
this.state = STATE_UNAWARE;
Phaser.Sprite.call(this, game, x, y, spritenames_by_type[spritetype]);
game.physics.arcade.enable(this);