Jump to content

What's the proper way to change the sprite animation frames data?


Recommended Posts

Hi there,


I have a 4x5(colums x rows) spritesheet. Each of this rows contains different animations applied to the same Sprite object, i.e:

this.load.spritesheet('body', 'assets/sprites/body.png', 80, 80);this.character = new Character(this.game, x, y, 'body');//Character class
var Character = function(game, x, y, spriteName) {
Phaser.Sprite.call(this, game, x, y, spriteName);

The Character class constructor create the default animations:

this.animations.add('walk', [0,1,2,0], 10, false);...

What I'm asking is for the best way (or just a way...) to update or change eventually the animation frames of a specific animation. For example to [12, 13, 14, 12].

I tried creating a new animation like:

this.animations.add('walk', [12, 13, 14, 12], 10, false);

but it doesn't seem to be working properly. I'm also tried to find a method to update the frame data (like animation.updateFrameData) no luck though.


What do you think about it?



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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