microspace Posted September 19, 2018 Share Posted September 19, 2018 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 More sharing options...
Yehuda Katz Posted September 20, 2018 Share Posted September 20, 2018 @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 More sharing options...
microspace Posted September 20, 2018 Author Share Posted September 20, 2018 This glitch which I described occurs only when camera follow player. Link to comment Share on other sites More sharing options...
samme Posted September 20, 2018 Share Posted September 20, 2018 You can try // After reset(…) game.stage.updateTransform(); game.camera.updateTarget(); game.camera.target.preUpdate() I'm not sure all of those are necessary. Link to comment Share on other sites More sharing options...
microspace Posted September 26, 2018 Author Share Posted September 26, 2018 @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 More sharing options...
Recommended Posts