It looks like you're new here. If you want to get involved, click one of these buttons!
--in init self.sprites = {} -- In create obj function function self:RemoveObj() table.insert(self.sprites, Bitmap or MovieClip) self.sprites[#self.sprites].dead = false self:addChild(self.sprites[#self.sprites]) end -- In EnterFrame for x=1, #self.sprites do -- self.sprites[x] events and actions end self:RemoveObj() --In remove obj function function self:RemoveObj() local dead = true repeat dead = false for x = 1, #self.sprites do if self.sprites.dead then self:removeChild(self.sprites[x]) table.remove(self.sprites, x) dead = true break end end until(not dead) end |
Comments
Likes: kinrpg
"v in pair", did not know this feature of Lua, cool, it already brings all the data of the current position inside "v".
"k: getParent (): removeChild (k)", so this is how you use getParent? So your monsters are an external class with their own init and enterframe?
Very cool. I will study this code.
In my case every time I create an enemy I add it to the enemies_list.
Likes: kinrpg
https://wiki.giderosmobile.com/index.php/Tutorial:_Making_a_2D_space_shooter_game
Likes: MoKaLux, kinrpg
How I didn't think of that before HAUAHAUAHAU
If order is matter, you can also use while loop:
Likes: MoKaLux