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 )