I get double image when re-enter a scene

I have been issue I have been trying to trying to solve for a long time…

When I re-enter a scene, I get double image, or delay movement …see both the videos
This is a simple multiplayer game that will send movement to socket.io to be send to other players.

Can someone gimme some hints on to why this happens or how to resolve it ??

Thanks

I have been reading on how the scene works and something about existing scenes are not garbage collection after exited the scenes …

https://github.com/jdotrjs/phaser-guides/blob/master/Basics/Part3.md

One potentially surprising behavior is that once a scene has been shut down it is not garbage collected but, rather, can be resumed via start() . When this happens the three creation functions get called once more. This means any state tracked in the scene class will be retained between a stopped state and the next create state. As a result special care must be taken to set a known initial value on everything requiring one.

video-1637371702 by stanley_seow, on Flickr

double image2 by stanley_seow, on Flickr

If you’re adding socket event listeners when starting the scene you need to remove them when stopping/restarting the scene.

1 Like

Thank you , the solution was spot on !!!