Jump to content

Reset sprite frame to 0 after overlap leave


JamesJam
 Share

Recommended Posts

What is the best approach to reset sprite to original frame 0 after the "dude" sprite leave the "step" sprite?

As far as I tried, the "dude" left the steps sprite to other frame numbers which feel like a glitch.

function preload() {   game.load.spritesheet('steps', 'steps.png', 100, 100);}function create() {game.world.setBounds(0, 0, 20000, 580)game.physics.startSystem(Phaser.Physics.ARCADE)cursors = game.input.keyboard.createCursorKeys()for(...){group.create(i*100, 150, 'steps')}}function overlapDetect(o,o1){   console.log("overlap",o1)}function update(){   game.physics.arcade.overlap(dude, group, overlapDetect, null, this);}if (cursors.up.isDown){} else if (cursors.down.isDown){}if (cursors.left.isDown){   dude.body.velocity.copyFrom(game.physics.arcade.velocityFromAngle(dude.angle, -300));}else if (cursors.right.isDown){   dude.body.velocity.copyFrom(game.physics.arcade.velocityFromAngle(dude.angle, 300));}
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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