Haha. I need some serious help here. I failed big time.
There is a cube, and an object to catch it. When the cube hits the object that catches it, I want there to be more cubes.
Also, I’d like for the cube to go away. Help!
Here’s my code.
[lua]local function spawnCrate()
local crate = display.newImage( “cratesmall.png” )
physics.addBody( crate, { density = 1.0, friction = 0.3, bounce = 0.2 } )
crate.x = math.random(250)
crate.y = math.random(-40)
end
timer.performWithDelay( 1000, spawnCrate, 2 )
local chute = display.newImage( “chute.png” )
chute.x = display.contentWidth/2
chute.y = 450
physics.addBody( chute, “static”, { friction=0.7 } )
local function onLocalCollision( event )
if ( event.phase == “began” ) then
timer.performWithDelay( 1000, spawnCrate, 1 )
elseif ( event.phase == “ended” ) then
print(“Finish”)
end
end
Runtime:addEventListener( “collision”, onLocalCollision )[/lua] [import]uid: 25216 topic_id: 11695 reply_id: 311695[/import]