Hello,
one tips is to put the ball in a group that moves in the opposite direction of the ball.
With this trick, the ball look like " fix" on the screen, and the group and others objects inside (rocks for exemple) moves together.
local group=display.newGroup() // this group will move vertically of 5 (the speed) every frame group.x,group.y=display.contentCenterX,display.contentCenterY local square=display.newRect(group,0,0,50,50) // square is on the center of the screen local spawnRock=function(\_groupGame) local rock=display.newRect(\_groupGame,0,0,10,10) rock.x=math.random(-display.contentCenterX,display.contentCenterX) // somewhere on X axis rock.y=square.y-display.contentCenterY // y position is finally on the top of the screen rock:setFillColor(1,0,0) end // the rock are insert on " group " during the timer below. local speed=5 // my increment - speed timer.performWithDelay(1,function(event) group.y=group.y+speed square.y=square.y-speed // the group of object increase, but I smartly decrease the y position of square on the group g // so he looks like "fix" on the screen if math.random(10)==1 then spawnRock(group) end // 10 percent probability to spawn a rock end,-1)
And next just add Runtime touch screen to move left and right and onCollision listener to detect when hitting the rock. Don’t forgot to manage the rock oustide the screen.
Or a Runtime touch screen to dynamicaly change the speed value.
Yvan.