Go from point A to B and Stay there. Possible?

Hello guys, i already searched a lot but could not find any material to help me. I would like to know if its is possible to tap the screen and a ball that is laying on the ground, go to the “roof” and stays there, and when i tap again, it goes back to the ground. In other words, tap the screen > object goes from point a to point b > stays there > tap > go from B to A, no animations to do that, just gravity working to bring back the ball to the ground.

Thank you very much for any help!

Not sure exactly what you’re looking for, but the following (I think) matches your description. The ball falls to the floor and when you tap the screen gravity reverses and it falls to the ceiling. Tap again and it falls to the floor, etc.

display.setStatusBar(display.HiddenStatusBar) local physics = require("physics") physics.start( true ) local centerX = display.contentCenterX local centerY = display.contentCenterY local screenLeft = display.screenOriginX local screenWidth = display.contentWidth - screenLeft \* 2 local screenRight = screenLeft + screenWidth local screenTop = display.screenOriginY local screenHeight = display.contentHeight - screenTop \* 2 local screenBottom = screenTop + screenHeight local gx, gravity = physics.getGravity( ) local ball local function flipFlop() local gx, gy = physics.getGravity( ) gravity = -gy physics.setGravity( 0, gravity ) end local topBumper = display.newRect( screenLeft, screenTop, screenWidth, 10 ) topBumper.x = centerX physics.addBody ( topBumper, "static" ) local bottomBumper = display.newRect( screenLeft, screenBottom, screenWidth, 10 ) bottomBumper.x = centerX physics.addBody ( bottomBumper, "static" ) ball = display.newCircle( centerX, centerY, 20 ) physics.addBody ( ball, "dynamic" ) ball.isSleepingAllowed = false Runtime:addEventListener ( "tap", flipFlop )

Whye, thank you very much, you rock!!!

Not sure exactly what you’re looking for, but the following (I think) matches your description. The ball falls to the floor and when you tap the screen gravity reverses and it falls to the ceiling. Tap again and it falls to the floor, etc.

display.setStatusBar(display.HiddenStatusBar) local physics = require("physics") physics.start( true ) local centerX = display.contentCenterX local centerY = display.contentCenterY local screenLeft = display.screenOriginX local screenWidth = display.contentWidth - screenLeft \* 2 local screenRight = screenLeft + screenWidth local screenTop = display.screenOriginY local screenHeight = display.contentHeight - screenTop \* 2 local screenBottom = screenTop + screenHeight local gx, gravity = physics.getGravity( ) local ball local function flipFlop() local gx, gy = physics.getGravity( ) gravity = -gy physics.setGravity( 0, gravity ) end local topBumper = display.newRect( screenLeft, screenTop, screenWidth, 10 ) topBumper.x = centerX physics.addBody ( topBumper, "static" ) local bottomBumper = display.newRect( screenLeft, screenBottom, screenWidth, 10 ) bottomBumper.x = centerX physics.addBody ( bottomBumper, "static" ) ball = display.newCircle( centerX, centerY, 20 ) physics.addBody ( ball, "dynamic" ) ball.isSleepingAllowed = false Runtime:addEventListener ( "tap", flipFlop )

Whye, thank you very much, you rock!!!