onTap Ball Jump

Hello all,

    I am creating a game and the user taps or touches the screen for the ball to bounce up. To give an idea I posted a picture. When the user taps the screen the ball bounces up and goes in the direction of the tap the user did. Anyone know of any docs or code that would do that ?

https://docs.coronalabs.com/guide/programming/01/index.html

Here bubby^

The radius is 50 and after the ball is finished bouncing, it hovers over the rectangle. Also how can I make it follow my finger tap ?

local composer = require( "composer" ) local scene = composer.newScene() local physics = require("physics") physics.start() local background local myRectangle local ball local finish function scene:create (event) local screenGroup = self.view background = display.newImageRect("backg.jpg", display.contentWidth,display.contentHeight) background.x = display.contentCenterX background.y = display.contentCenterY screenGroup:insert(background) myRectangle = display.newRect( 50, 300, 40, 20 ) myRectangle:setFillColor( 0.5 ) ball = display.newImage("balll.png") ball.x = 50 ball.y = 60 ball:scale( 1.5, 1.5 ) ball.alpha = 0.8 screenGroup:insert(ball) finish = display.newImage("finish.png") finish.x = 150 finish.y = 300 screenGroup:insert(finish) physics.addBody( myRectangle, "static" ) physics.addBody( ball, "dynamic", { radius=50, density=1, bounce=0.3 } ) local function pushBall() ball:applyLinearImpulse( 0, -0.75, ball.x, ball.y ) end ball:addEventListener( "tap", pushBall) end function scene:show(event) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then print("show started") elseif ( phase == "did" ) then print("show showing objects") end end function scene:hide(event) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then print("hide started") elseif ( phase == "did" ) then print("hide removing objects") end end function scene:destroy(event) end scene:addEventListener("create", scene) scene:addEventListener("show", scene) scene:addEventListener("hide", scene) scene:addEventListener("destroy", scene) return scene

Is this what you mean:

local circle = display.newCircle( 50, 50, 100 ) circle:setFillColor( 0, 1, 0 ) local function moveCircle( event ) circle.x = event.x circle.y = event.y end Runtime:addEventListener( "touch", moveCircle )