Jump to content

Extending sprite - animations


Recommended Posts

How would I add animations to a class I've extended from sprite? 

I'm trying to follow the information Extending Sprite Demos 1 and 2 but neither animate the sprites and if I add 'this.animations.add' in the update function I get the error 'animations is not defined'.

The code to my class is here:


Puppy = function(thisGame,x,y) {	Phaser.Sprite.call(this,thisGame,x,y,'puppy');};Puppy.prototype = Object.create(Phaser.Sprite.prototype);Puppy.prototype.constructor = Puppy; Puppy.prototype.create = function() {	this.animations.add('idleleft',[0,1,2],4,true);    this.animations.add('idleright',[3,4,5],4,true);    this.animations.play('idleright');};
puppy = new Puppy(this,100,256);this.add.existing(puppy);

Other than animations it seems to work. Any help would be greatly appreciated. 

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...