Hello all yet again, I am experiencing this bug. I have an enemy that I spawn. Once he is spawned I have him transition to a certain point on the y-axis. On completion of the transition he is to be removed. I have used a similar method for spawning and removing in this program before and haven’t any trouble with it. here is the code below.
[lua]local function spawnUrchin( event )
urchin = display.newImage(“jellyfishNew2.png”)
urchin.name = “urchin”
urchin.xScale = 0.5
urchin.yScale = 0.5
physics.addBody(urchin, “static”, {density=1.0, friction=0.5, bounce=0.0, radius= 20})
urchin.y = 320
urchin.x = math.random(50,480)
–urchin.preCollision = onPreCollision
–urchin:addEventListener(“preCollision”, urchin)
–urchin.collision = onCollision
–urchin:addEventListener(“collision”, urchin)
localGroup:insert(urchin)
function destroyUrchin (urchin)
function destroyUrchinFinal (urchin)
if urchin ~= nil then
localGroup:remove(urchin)
urchin = nil
end
end
timer.performWithDelay(20, destroyUrchinFinal, -1)
end
if gamePhase == “phase one” then
transition.to(urchin, {time = 20000, y = 30, onComplete = destroyUrchin})
elseif gamePhase == “phase two” then
transition.to(urchin, {time = 15000, y = 0})
elseif gamePhase == “phase three” then
transition.to(urchin, {time = 10000, y = 0})
elseif gamePhase == “phase four” then
transition.to(urchin, {time = 5000, y = 0})
elseif gamePhase == “phase five” then
transition.to(urchin, {time = 2500, y = 0})
elseif gamePhase == “phase six” then
transition.to(urchin, {time = 2000, y = 0})
end
return urchin
end [import]uid: 49863 topic_id: 29049 reply_id: 329049[/import]