I am creating a game with balls and when they drop from the screen some of them are usually off of the screen so can someone help me on how to change this ?
local function spawnBall() for i=1,numberBall do Ball = display.newCircle(100, 80, 10) physics.addBody(Ball, "dynamic", {density=.1}) Ball:setFillColor( 0.7 ) Ball:setStrokeColor( 0, 0, 5 ) Ball:applyLinearImpulse(-.05, .05, 0, 0) Ball.x = math.random(-10, 400); Ball.y = -40; transition.to( Ball, { time=math.random(2000,8000), x=math.random(-10,400) , y=600, onComplete=clearBall } ); physics.addBody( Ball, "dynamic", { density=0.1, bounce=0.1, friction=0.1, radius=0 } ); --Adding touch event end end
