Jump to content

Player animation problem with spritesheet frames


Recommended Posts



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




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??




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

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...