removePhysics() - lets you remove the DisplayObject from the physics world
to add back to the physics world, use the addPhysics() method
Hello. I have a drag and drop activity with Physics. When the activity is finished I do removePhysics which I restart. That is I remove everything and add it back. But this causes a lot of slowness.
I don't want to use window.location.reload().
Is there a way to refresh with Physics?
1 Like
Not sure what is causing the "slowness". Do you mean it is slow to code? Or that the app is slow as the physics is remade?
If you are going to reuse the same objects you do not need to removePhysics every time. You can put them back to their start positions like we did here: https://codepen.io/zimjs/pen/gbbmNpq
If you just want to pause physics you can put them, initially, all in a new Container(W,H) and then removeFrom() the container and physics.pause() when you do not want them and addTo() and physics.pause(false) when you do.
Let us know if any of this helps - otherwise... let us know some more details.
What slows it down. To restart, delete the physics and add physics again. But I did the restart positions with your suggestion. It solved the problem.
1 Like