Wondering if anyone has encountered this before. If I choose my level from the level select menu, the menu loads all items fine. If I reload the level using my reload button it works fine. The issue lies in when I finish the previous level and press the “next” button to go to the next level. On some of my levels when I transition from the previous level to the next one, the physics objects seem to spawn in slightly different areas. This is apparent when I have physics objects very close to each other (i.e. stacked crates). This may cause the objects to react to each other, possibly topple over, fall through the floor etc. If I reload the level, it works just fine. Anyone else encounter this? [import]uid: 31262 topic_id: 12204 reply_id: 312204[/import]
I had a similar problem. What ended up working for me was to make sure to clean up the physics world completely before starting the next level. That meant iterating through all the physics bodies in the world and deleting them before loading the next level.
I also had to call physics.stop() before loading the next level and restarting it. (be careful with that! There’s a random crash bug that occurs if you call physics.stop() while there are still physics bodies in the world. You have to delete EVERYTHING in the world before calling physics.stop.)
Without doing the above I would get some weird phantom physical effects on certain physical objects when I started the next level.
[import]uid: 9422 topic_id: 12204 reply_id: 44541[/import]
Thanks for your reply XenonBL. Is it possible those physics items from the previous level are most likely overlapping my new physics items on the next level, causing them to interact? This would make a lot of sense. I will try what you suggest. Thank you very much, appreciated. [import]uid: 31262 topic_id: 12204 reply_id: 44547[/import]
For me the symptoms suggested that the last physics step from the previous level was still playing itself out and somehow interacting with objects in the new level, even though the old objects were no longer visible.
By the way, I don’t think this issue has anything to do with Director. At least, I know that’s true for my app since I’m not currently using Director. Box2D just seems to be a finicky beast to control, and I suspect Ansca’s implementation of it has introduced a few more peculiarities. [import]uid: 9422 topic_id: 12204 reply_id: 44601[/import]
Sorry to bring this up again after so long but I am retouching upon this issue. I have tried to remove all objects in previous levels however it didn’t seem to make any difference. As soon as I switch to the next level, my boxes with physics are knocked to the side. If I reload the level it behaves properly. Has anyone figured out a way around this? [import]uid: 31262 topic_id: 12204 reply_id: 93187[/import]
That’s exactly the problem im facing right now.
Anyone solved it? [import]uid: 124613 topic_id: 12204 reply_id: 93371[/import]
Hey, i solved the problem.
Check what i have done in this link:
http://developer.anscamobile.com/forum/2012/01/24/remove-all-previous-created-groups-when-new-scene-already-opened#comment-93578 [import]uid: 124613 topic_id: 12204 reply_id: 93579[/import]
Hey joaobergamo, thanks for the reply. I’m not sure I understand though. I don’t do any delta time calculations, I just start the next level and start physics immediately. Do you think it would help if I delayed starting the physics? [import]uid: 31262 topic_id: 12204 reply_id: 93585[/import]
Now i think i understood your problem, and to have sure how to fix it, i should take a look on your code.
But, try to put your code inside one function, and execute this function with timer.performWithDelay() before start the scene.
Or, put a button Start on yout scene above the screen, and starts physics only when the player tap on it. This should prevent the error to happen.
[import]uid: 124613 topic_id: 12204 reply_id: 93773[/import]
Just for future reference, I finally found a way around this. What I did was transition to a temporary screen, kinda like a loading screen and put a delay of 300ms on it. From there I transitioned to the next level. The important thing is you need to start physics on this load screen. Hopefully this helps someone. [import]uid: 31262 topic_id: 12204 reply_id: 95017[/import]