Im testing the tutorial online (Make a game in 8 minutes) and I entered this code -
local ball = display.newImage(“super_ball.png”)
ball.x = 40
ball.y = -1
ball:setReferencePoint( display.CenterReferencePoint )
physics.addBody( ball, {bounce=0.1, radius=23, friction=0.8} )
function moveBall(event)
ball:applyLinearImpulse( 0, -0.05, event.x, event.y )
end
ball:addEventListener( “touch”, moveBall)
It works for the most part, but if I hit the right side of the ball, it doesn’t go left, it just spins faster and faster each time I touch it, and likewise with the left side.
but you are applying a linear force upwards from the point you touched… why would it go left?
[import]uid: 6645 topic_id: 7510 reply_id: 26651[/import]
watch that video and scroll to 4:05
when I enter that code, it doesn’t do what his balloons do [import]uid: 39628 topic_id: 7510 reply_id: 26654[/import]
his dont move laterally until they hit the ground though or each other. which makes sense for rotating bodies [import]uid: 6645 topic_id: 7510 reply_id: 26657[/import]
wow I didn’t even notice that… thank you haha excuse my noobness. would you have any idea how I would make it do what I mentioned though?
like if I hit the right side, it’d go left, if I hit the bottom, it’d go up (opposites)? [import]uid: 39628 topic_id: 7510 reply_id: 26659[/import]