More wandering sprite work

This commit is contained in:
2014-06-11 21:17:23 -07:00
parent c5ac1c7767
commit 9a9a9c4eaf

View File

@@ -220,6 +220,16 @@ var WanderingSprite = function(game, x, y, spritetype) {
Phaser.Sprite.call(this, game, x, y, spritenames_by_type[spritetype]); Phaser.Sprite.call(this, game, x, y, spritenames_by_type[spritetype]);
game.physics.arcade.enable(this); game.physics.arcade.enable(this);
this.body.checkWorldBounds = true; this.body.checkWorldBounds = true;
addAnimation(this, 'bipedwalkleft');
addAnimation(this, 'bipedwalkright');
addAnimation(this, 'bipedwalkup');
addAnimation(this, 'bipedwalkdown');
addAnimation(this, 'bipedrunleft');
addAnimation(this, 'bipedrunright');
addAnimation(this, 'bipedrunup');
addAnimation(this, 'bipedrundown');
} }
WanderingSprite.prototype = Object.create(Phaser.Sprite.prototype); WanderingSprite.prototype = Object.create(Phaser.Sprite.prototype);
@@ -228,7 +238,7 @@ WanderingSprite.prototype.constructor = WanderingSprite;
var GameState = function(game) { var GameState = function(game) {
} }
GameState.prototype.addAnimation = function(obj, anim) function addAnimation(obj, anim)
{ {
a = moonlightSettings['animations'][anim] a = moonlightSettings['animations'][anim]
obj.animations.add(anim, a['frames'], a['speed'], a['loop']) obj.animations.add(anim, a['frames'], a['speed'], a['loop'])
@@ -272,14 +282,14 @@ GameState.prototype.create = function()
this.physics.arcade.enable(player); this.physics.arcade.enable(player);
player.body.collideWorldBounds = true; player.body.collideWorldBounds = true;
this.addAnimation(player, 'bipedwalkleft'); addAnimation(player, 'bipedwalkleft');
this.addAnimation(player, 'bipedwalkright'); addAnimation(player, 'bipedwalkright');
this.addAnimation(player, 'bipedwalkup'); addAnimation(player, 'bipedwalkup');
this.addAnimation(player, 'bipedwalkdown'); addAnimation(player, 'bipedwalkdown');
this.addAnimation(player, 'bipedrunleft'); addAnimation(player, 'bipedrunleft');
this.addAnimation(player, 'bipedrunright'); addAnimation(player, 'bipedrunright');
this.addAnimation(player, 'bipedrunup'); addAnimation(player, 'bipedrunup');
this.addAnimation(player, 'bipedrundown'); addAnimation(player, 'bipedrundown');
this.camera.follow(player, Phaser.Camera.FOLLOW_TOPDOWN); this.camera.follow(player, Phaser.Camera.FOLLOW_TOPDOWN);
controls = game.input.keyboard.createCursorKeys(); controls = game.input.keyboard.createCursorKeys();