what i wanna do is :
a spawn function for the crates
a spawn function for the bomb
when crates hit floor it removeself and then make a false image of the crate (cratefalse)
same when crate hit a “cratefalse”
this way i make a pile of “cratefalse” that i can move with the pad (i dont have inserted the pad function cuz it works good luckly :))
now when bomb are spawned and hit a “cratefalse” i want that all the cratefalse are removed, but this dont work
i tryed also to set target and object in collision but still dont work!!
can some1 help me pls!!
[lua]local function spawncrate()
local crate = display.newImage (“crate.png”)
crate.x = math.random( 480 )
crate.y = -100
localGroup:insert(crate)
physics.addBody( crate, { density=2.0,
friction=0.5,
bounce=0.3 } )
local function removecrate()
crate:removeSelf()
return crate
end
local falsecratecount = 0
function spawnfalsecrate(event)
–this part is probly wrong
local cratefalse = {}
falsecratecount = #cratefalse + 1
local i = falsecratecount
cratefalse[i] = display.newImage(“crate.png”)
cratefalse[i].myName = (“cratefalse_” … “_#cratefalse”)
cratefalse[i].x = crate.x
cratefalse[i].y = crate.y + 5
physics.addBody(cratefalse[i], “static”,{bounce=0, density=1.0})
localGroup:insert(cratefalse[i])
print(#cratefalse)
function movecrate (event)
cratefalse[i].x= cratefalse[i].x + motionx
end
timer7 = timer.performWithDelay(1,movecrate,0)
end
function crateon(e)
removecrate()
spawnfalsecrate(event)
end
function cratefristcollision (event)
if event.other.myName == “floor” then
timer.performWithDelay( 50, crateon,0 )
elseif event.other.myName == (“cratefalse_” … “_#cratefalse”) then
timer.performWithDelay( 50, crateon,0 )
end
end
crate:addEventListener(“collision”, cratefristcollision)
return crate
end
timer.performWithDelay( 3000, spawncrate, 0 )
local function spawnbomb()
local bomb = display.newImage (“bomb.png”)
bread.x = math.random( 480 )
bread.y = -100
physics.addBody( bomb, { density=2.0,
friction=0.5,
bounce=0.3 } )
function bombfristcollision (event)
if event.other.myName == “floor” then
bomb:removeSelf() end
if event.other.myName == (“cratefalse_” … “_#cratefalse”) then
bomb:removeSelf()
cratefalse[i]:removeSelf()
end
end
bomb:addEventListener(“collision”,bombfristcollision)
end
timer.performWithDelay( 8888, spawnbomb, 0 )
[/lua] [import]uid: 99803 topic_id: 18151 reply_id: 318151[/import]
[import]uid: 99803 topic_id: 18151 reply_id: 69549[/import]
[import]uid: 52491 topic_id: 18151 reply_id: 69657[/import]