More wandering sprite work

This commit is contained in:
2014-06-11 21:05:18 -07:00
parent e94094c8e2
commit 0c5a913080

View File

@@ -176,24 +176,7 @@ SPRITE_TOWNSFOLK_GUARD1 = 9;
SPRITE_TOWNSFOLK_GUARD2 = 10; SPRITE_TOWNSFOLK_GUARD2 = 10;
var WanderingSprite = function(game, x, y, spritetype) { var WanderingSprite = function(game, x, y, spritetype) {
var spritenames_by_type = [ this.update = function()
'townsfolk-male-1',
'townsfolk-male-2',
'townsfolk-male-3',
'townsfolk-male-4',
'townsfolk-female-1',
'townsfolk-female-2',
'townsfolk-female-3',
'townsfolk-female-4',
'townsfolk-guard-1',
'townsfolk-guard-2'
];
Phaser.Sprite.call(this, game, x, y, spritenames_by_type[spritetype]);
game.physics.arcade.enable(this);
this.body.checkWorldBounds = true;
}
WanderingSprite.prototype.update = function()
{ {
if ( game.rnd.integerInRange(0, 1) == 1 ) if ( game.rnd.integerInRange(0, 1) == 1 )
return; return;
@@ -219,6 +202,23 @@ WanderingSprite.prototype.update = function()
} }
} }
var spritenames_by_type = [
'townsfolk-male-1',
'townsfolk-male-2',
'townsfolk-male-3',
'townsfolk-male-4',
'townsfolk-female-1',
'townsfolk-female-2',
'townsfolk-female-3',
'townsfolk-female-4',
'townsfolk-guard-1',
'townsfolk-guard-2'
];
Phaser.Sprite.call(this, game, x, y, spritenames_by_type[spritetype]);
game.physics.arcade.enable(this);
this.body.checkWorldBounds = true;
}
WanderingSprite.prototype = Object.create(Phaser.Sprite.prototype); WanderingSprite.prototype = Object.create(Phaser.Sprite.prototype);
WanderingSprite.prototype.constructor = WanderingSprite; WanderingSprite.prototype.constructor = WanderingSprite;