i am just developing a game with static and dynamic physics objects. I also use storyboard for scene transitions.
Now i implemented a reload button which simply reloads the Scene with storyboard.reloadScene(). In short the structure of my storyboard Scenes are as follows:
scene:createScene( event )
– i do nothing
scene:willEnterScene( event )
– physics.start()
– load Level (graphics incl. physics bodies)
scene:enterScene( event )
– add Event listeners
scene:exitScene( event )
– remove Event listeners
– remove graphics and physics objects.
– physics.stop() or physics.pause()
Everything would work great if physics.stop() would not crash the Simulator and also the app. It crashes randomly. sometimes after 3 refreshes sometimes after 30 refreshes.
So i replaced physics.stop with physics.pause(). Now the app and the Simulator does not Crash anymore. But the issue now is that my dynamic physics objects are a little bit displaced and the game is unplayable. Please see the attached pic. I have no idea anymore what i can do. Is there any fix in the Pipeline concerning the physics.stop() bug?
Thanks in advance for any ideas or help.
Thomas
Edit: i just found out that when i move my level creation code from the willEnterScene to the enterScene the displacement is gone. why?
I just found out that the random crashes happen, when Pivot Joints are NOT removed before physics.stop() is executed. It would be great if this could be fixed in the near future. Thanks in advance.
I just found out that the random crashes happen, when Pivot Joints are NOT removed before physics.stop() is executed. It would be great if this could be fixed in the near future. Thanks in advance.
When and where you pause/stop the physics engine (which event in the Composer framework) is essential. Also, using physics.stop() needs to be treated carefully, since this call “destroys” the entire physics world, and may result in crashing if there are some lingering activities or calls that reference the physics engine. Personally, I never use .stop(), but only .pause(), since there’s typically not a reason to destroy the entire physical world.
I ended up just not using physics.stop - it is definitely buggy on the ipad (which bugs are not manifest in corona or xcode simulators). Physics.stop is convenient as it ensures that everything is cleared from the physics world and can be a big timer saver. However, you’ll probably end up having to carefully track all of your physics objects and remove/destroy them at the appropriate times, particularly joints.
When and where you pause/stop the physics engine (which event in the Composer framework) is essential. Also, using physics.stop() needs to be treated carefully, since this call “destroys” the entire physics world, and may result in crashing if there are some lingering activities or calls that reference the physics engine. Personally, I never use .stop(), but only .pause(), since there’s typically not a reason to destroy the entire physical world.
I ended up just not using physics.stop - it is definitely buggy on the ipad (which bugs are not manifest in corona or xcode simulators). Physics.stop is convenient as it ensures that everything is cleared from the physics world and can be a big timer saver. However, you’ll probably end up having to carefully track all of your physics objects and remove/destroy them at the appropriate times, particularly joints.