Jump to content

Sprite gets separate from body


microspace
 Share

Recommended Posts

Strange bug occures when I try to move sprite to initial position in game. I use this command: 

this.gamesprite.reset(lastSuccessfullPosition.x, lastSuccessfullPosition.y);

For a moment sprite gets separate from body. At this moment body overlaps a wall and collision callback is called. For this reason every time I press reset button, sprite behaves as if it hit the wall.

 

Link to comment
Share on other sites

@microspace Despite that reset is widely used in tutories, I personally faced many strange behaviours of it. It does almost nothing special https://github.com/photonstorm/phaser/blob/v2.6.2/src/gameobjects/components/Reset.js#L30 and if you need to move sprite back, better do it yourself. As you can see reset itself does something which may not important for your case and you are losing CPU time.

Link to comment
Share on other sites

@samme, can you please explain how to use these functions, that you listed?

I tried to use game.stage.updateTransform(); after my reset function, but no result.

After randomly changing the code I've found that when I disable `fresh` parameter, the glitch disappears.

this.pegmanSprite.fresh = false;

Who can explain why is this happening?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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