Problem with transition

i am developing a game…one tank on ground and so many object are flying on sky, when i am firing bullet from tank, if bullet collide with object then object are removing and after 100 firing tank are removing self, then Gave over…after Game over i want to remove all objects who are flying on screen(actually cancel all transition and clean screen ) any help:

Code of object who are flying on screen…

[lua] if (rand <= 50) then
enytnk = display.newImage(“tankbody.png”)
enytnk.x = 40
enytnk.y = 40
enytnk.name = “enytnk”
enytnk.isLive = true
physics.addBody(enytnk, { friction = 0, density = 100 })
tr1=transition.to(enytnk, {
delay = 50,
time = 20000,
x = 1024,
y = 60,
alpha = 1,

})[/lua]

Code of game over

[lua]transition.cancel(tr1)[/lua] [import]uid: 87661 topic_id: 20328 reply_id: 320328[/import]

you’d have to place all your enytnk’s that you spawn inside a table, then clear that table

[code]local enytnk = {}
local i = 0

if (rand <= 50) then
i = i + 1
enytnk[i] = display.newImage(“tankbody.png”)
enytnk[i].x = 40
enytnk[i].y = 40
enytnk[i].name = “enytnk”
enytnk[i].isLive = true
physics.addBody(enytnk[i], { friction = 0, density = 100 })
tr1=transition.to(enytnk[i], {
delay = 50,
time = 20000,
x = 1024,
y = 60,
alpha = 1,

})

[/code]

Try that, when clearing all the objects just clear the table [import]uid: 14018 topic_id: 20328 reply_id: 79468[/import]

hi@Mitaten
thanks for help but i did cancel to table, it c’d disappear to current object who are flying on screen(i want,when game over then same time disappears who are flying object on screen ):
plz help::>

i tryed both:
[lua]table.remove(enytnk[i])
and
table.remove(enytnk)[/lua]
[import]uid: 87661 topic_id: 20328 reply_id: 79639[/import]

Is that table.remove(enytnk[i]) inside a loop? Else you’re only removing one object. [import]uid: 52491 topic_id: 20328 reply_id: 79662[/import]

try enytnk = nil [import]uid: 14018 topic_id: 20328 reply_id: 79681[/import]

hi…i tryed both but not working, only remove last object who are flying …please help me…

code of loop…>

[lua]function spwanenemy()
rand = math.random(100)
local enytnk = {}
local i = 0

if (rand <= 50) then
i = i + 1
enytnk[i] = display.newImage(“tankbody.png”)
enytnk[i].x = 40
enytnk[i].y = 40
enytnk[i].name = “enytnk[i]”
enytnk[i].isLive = true
physics.addBody(enytnk[i], { friction = 0, density = 100 })
tr1=transition.to(enytnk[i], {
delay = 50,
time = 20000,
x = 1024,
y = 60,
alpha = 1,

})

local function GameOver1()
table.remove(enytnk[i])
enytnk[i] = nil
end
end
GameOver1()
tem = timer.performWithDelay(5000, spwanenemy, -1)[/lua] [import]uid: 87661 topic_id: 20328 reply_id: 79719[/import]

Try what Peach Pellen suggested, create a loop that erase all of the objects…

for n = 1, #enytnk do  
enytnk[n]:removeSelf()  
enytnk[n] = nil  
end  

that should do the trick [import]uid: 14018 topic_id: 20328 reply_id: 79725[/import]