my game have 2 scenes which could be switched by storyboard.
the 2 scenes have different physics gravity settings.
before I gotoScene 2 form scene 1, I pause() the physics first ( the physics is a global var ).
scene 2’s gravity is tilt based.
before I switch back to scene 1 from scene 2, I pause the physics again and remove the listener for “accelerometer”.
but when I come back to scene 1, the physics gravity seems messed up. the “accelerometer” still works.
also please tell me what’s the different between physics.stop() and physics.pause() ?
because I first tried physics.stop() instead of pause() when switching scenes, but it didn’t work.
thanks a lot! [import]uid: 99926 topic_id: 22605 reply_id: 322605[/import]
So it sounds like the accelerometer listener maybe isn’t being removed properly; is that it? Or it isn’t being removed but also gravity is “weird” in a way other than still adjusting based on tilt? [import]uid: 52491 topic_id: 22605 reply_id: 90430[/import]
this function is in function scene:createScene( event ), maybe I shouldn’t define this function in function scene:createScene( event )?
seems I always get a negative xgravity, it’s like every body is pulled to the left side of the screen.
by the way my scene 1 does have a negative x gravity, but before I switch to scene 2 I pause the physics(the global var) and in scene 2 I physics.start(), and set the gravity listen to onTilt. [import]uid: 99926 topic_id: 22605 reply_id: 90435[/import]
Use a print statement to see what the xGravity is doing is my advice in this situation; is it reacting at all? If they always go left regardless of tilt it sounds like there may be an issue in the function or listener.
(I see you are displaying xGravity somewhere with your code, assuming that is still the case you could use that rather than a print statement - but what value is being returned?) [import]uid: 52491 topic_id: 22605 reply_id: 90445[/import]