actually it can still be static
[lua]local physics = require(“physics”)
local rnd = math.random
physics.start()
local divider = display.newLine(0,300,320,300)
divider:setColor(255,0,0)
divider.width=1
divider.alpha=0.2
local divider2 = display.newLine(0,400,320,400)
divider2:setColor(255,0,0)
divider2.width=1
divider2.alpha=0.2
local line = display.newRect(0,300,170,20)
line:setFillColor(255,0,0)
line.is=“line”
line.isPlatform=true
physics.addBody(line, “static”, {density=1})
local function removeBall(obj)
Runtime:removeEventListener(“enterFrame”, obj)
obj:removeSelf()
end
local function lineUp(event)
transition.to(line, {time=50, y=310})
end
local function globalCollision(event)
local obj1 = event.object1
local obj2 = event.object2
– if round ball hits line
if(obj2.is==“round” and obj1.is==“line”) then
transition.to(obj1, {time=100, y=obj1.y+10, onComplete=lineUp})
removeBall(obj2)
end
end
local function newBall()
local ball
local radius = rnd(50)+5
local pick = math.floor(rnd(2))
if(pick==1) then
ball = display.newCircle(rnd(280)+20, 20, radius)
physics.addBody(ball, “dynamic”, {density=0.5, bounce=0.5,radius=radius})
ball.is=“round”
elseif(pick==2) then
ball = display.newRect(rnd(280)+20, 20,4,4)
physics.addBody(ball, “dynamic”, {density=1, bounce=0.1})
ball.is=“square”
end
ball:setFillColor(0,255,0)
ball.isBullet=true
– to be safe remove balls if they fall off the lower part of the screen
– otherwise they will continue falling forever
ball.enterFrame=function(self, event)
local ypos = self.y
if(ypos > 300) then self:setFillColor(255,0,0) end
if(ypos > 400) then removeBall(self) end
end
Runtime:addEventListener(“enterFrame”, ball)
end
Runtime:addEventListener(“collision”, globalCollision)
timer.performWithDelay(100,newBall,-1)[/lua] [import]uid: 6645 topic_id: 3907 reply_id: 12686[/import]