Jump to content

Player animation problem with spritesheet frames


Mizukage
 Share

Recommended Posts

Hi.

 

If I have some player spritesheets, 9 frames in a row then I can use code like this example 

 

 

dude.png

player = game.add.sprite(90, game.world.height-150, 'Goku');player.animations.add('left', [0, 1, 2, 3], 10, true);player.animations.add('right', [5, 6, 7, 8], 10, true);

But problem is when I have sprtiesheet with two rows of frames, how do it then??

 

scottpilgrim_multiple.png

 

Link to comment
Share on other sites

So here is my preloader asset: 

 

this.sprite = this.game.load.spritesheet('player1' , '../path/to/file.png', width, height);

 

the sprites width is 32 and the height is 48. Then when you do animations everything is sequential.

 

So using your scott pilgram frames to run left you would do something like.

 

this.sprite.animations.add('runLeft', [8,9,10,11,12,13,14,15], 20, true);

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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