Hi,
I’m having issues with the Make a game in 8 minutes tutorial. I have followed it using images I have, and cannot get the ball to move relative to the touch input rather than the balls x, y position. Here is my code, can any one see where I am going wrong?
Thanks.
[lua]_W = display.contentWidth
_H = display.contentHeight
– Add Physics Engine and Start
local physics = require(“physics”)
physics.start()
display.setStatusBar(display.HiddenStatusBar)
– Import Images
local background = display.newImage(“background.png”)
local floor = display.newImage(“floor.png”)
floor.y = _H-20
physics.addBody(floor,“static”,{friction = 10, bounce = 0})
local ball = display.newImage(“ball.png”)
ball.x = _W/2
physics.addBody(ball,{bounce = 0.2, radius = 40})
function moveBall(event)
local ball = event.target
ball:applyLinearImpulse(0,-0.1,event.x,event.y)
end
ball:addEventListener(“touch”,moveBall)[/lua]