How can I let the ball goes sideways? So if I tap right on the ball, the ball goes left & if I tap left on the ball, the ball goes right.
It’s all about the 36th line:
[code]local storyboard = require “storyboard”
local scene = storyboard.newScene()
local widget = require “widget”
display.setStatusBar( display.HiddenStatusBar )
local physics = require(“physics”)
physics.start()
physics.setGravity(0, 29.4)
–physics.setDrawMode(“hybrid”)
local background = display.newImage ( “road.jpg” )
local ball = display.newImageRect( “SkySoccer Ball.gif”, 100, 100 )
ball.x = display.contentCenterX
ball.y = display.contentCenterY
local leftWall = display.newRect(0, 0, 0.1, display.contentHeight )
local rightWall = display.newRect(display.contentWidth, 0, 0.1, display.contentHeight )
local ceiling = display.newRect(0, 0, display.contentWidth, 0.1 )
physics.addBody(leftWall, “static”, { bounce = 0.1} )
physics.addBody(rightWall, “static”, { bounce = 0.1} )
physics.addBody(ceiling, “static”, { bounce = 0.1} )
local white = display.newImageRect( “white.png”, 320, 0.1 )
white.x = display.contentCenterX
white.y = 480
physics.addBody(ball, { bounce = 0.5, radius = 40, friction = 1.0} )
physics.addBody(white, “static”, { bounce = 0.0, friction = 1.0})
function moveBall(event)
if event.phase == “began” then
ball:applyLinearImpulse( 0, -1.5, ball.x, ball.y )
return false
end
end
ball:addEventListener(“touch”, moveBall)[/code]
Can you please help me??? [import]uid: 203192 topic_id: 34116 reply_id: 334116[/import]