Word bubbles

This commit is contained in:
2014-06-11 23:06:50 -07:00
parent 5e677d6ce8
commit 4756c5738f

View File

@@ -290,12 +290,12 @@ var AISprite = function(game, x, y, spritetype) {
break; break;
} }
} }
console.log(aistate); console.log(aistate);
console.log(this.sprite_group); console.log(this.sprite_group);
var mylines = moonlightDialog['status'][this.sprite_group][aistate]; var mylines = moonlightDialog['status'][this.sprite_group][aistate];
var text = mylines[game.rnd.integerInRange(0, mylines.length)]; this.bubble_text = mylines[game.rnd.integerInRange(0, mylines.length)];
var style = {font: '12px Arial Bold', fill: '#ffffff', align: 'center'} this.bubble_style = {font: '12px Arial Bold', fill: '#ffffff', align: 'center'}
this.bubble = game.add.text(this.x, this.y, text, style);
} }
this.clearWordBubble = function() this.clearWordBubble = function()
@@ -308,8 +308,6 @@ var AISprite = function(game, x, y, spritetype) {
{ {
if ( game.rnd.integerInRange(0, 100) < 95 ) if ( game.rnd.integerInRange(0, 100) < 95 )
return; return;
this.bubble.x = this.x;
this.bubble.y = this.y - this.bubble.height;
var running = false; var running = false;
if ( game.rnd.integerInRange(0, 100) > 90 ) { if ( game.rnd.integerInRange(0, 100) > 90 ) {
running = true; running = true;
@@ -319,6 +317,10 @@ var AISprite = function(game, x, y, spritetype) {
this.setWordBubble(); this.setWordBubble();
} }
if ( this.bubble !== null ) {
this.bubble.destroy();
this.bubble = game.add.text(this.x, this.y - 20, text, style);
}
switch ( game.rnd.integerInRange(0, 4) ) { switch ( game.rnd.integerInRange(0, 4) ) {
case 0: { case 0: {
setSpriteMovement(this, running, 'up'); setSpriteMovement(this, running, 'up');