Hi all,
This is kinda two part question both interrelated.
I have a scene which has an object which is a newImageRect(), the scene has gravity and I set the gravity to 0 by physics.setGravity( 0, 0 ). I also call physics.addBody(myObject,“dynamic”,{bounce=0, friction=0.2, radius=98}) so I can interact with the myObject. The first time I load the scene the object appears in the correct Y and X coordinate, however when I move out out of the scene and back to it the object moves a little up or down and stops but doesn’t appear like the first time the scene starts in the correct Y position.
My question is kinda how can I move out of a scene and go back to it as though I am going to that scene for the first time - the text objects I have are fine but I think it has to do with the physics and the object is dynamic in that it appears to drop or go up temporarily before it stops when going back to the scene again.
I really cant understand this??
The dynamic object is this code in the create()
myObject= display.newImageRect("images/myObject.png",200,200) myObject.x = display.contentCenterX myObject.y = display.contentCenterY physics.addBody(myObject,"dynamic",{bounce=0, friction=0.2, radius=98}) myObject.angularDamping = 1 myObject:applyTorque(4) sceneGroup:insert(myObject) physics.setGravity( 0, 0 )
I just want everything to appear in the correct place including the dynamic myObject. In the BackButton override do I need to do something further in there to ‘reset everthing’
My current backbutton override looks like this:
-- Called when a key event has been received local function onKeyEvent( event ) -- If the "back" key was pressed on Android or Windows Phone, make sure it gets back to menu if ( event.keyName == "back" ) then local platformName = system.getInfo( "platformName" ) if ( platformName == "Android" ) or ( platformName == "WinPhone" ) then composer.removeScene("scenes.total\_distance\_game\_default" ) composer.gotoScene("scenes.menu") end end return true end Runtime:addEventListener( "key", onKeyEvent )