Jump to content

How to create sprite walking animation on cursor isDown


Recommended Posts

I have a sprite sheet what I want todo is when I press left or right key I want the sprite to animate to dx distance. Can someone give me an example on how achieve this? Currently this is what I have

//in preload//load in example sprite sheet this.game.load.spritesheet('ms', './res/assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);//in createsprite.animations.add('walk');//in update if (cursors.left.isDown){            sprite.scale.x = -1; //this inverts the image to face left            //stuck here, basically want to animate sprite walking for dx distance            sprite.body.velocity.x = -150;}

hope its clear on what question I'm asking. Any help would be appreciated.


Link to comment
Share on other sites

  • 2 years later...

  • Recently Browsing   0 members

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