i just mentioned your gameover since it’s not called there, and not callable from elsewhere since local, so it’s “dead code” as is - but maybe it’s just a stub for work in progress and will make sense later?
you can just “decorate” your corona display objects with user-defined properties, like “alive”, or “isDead” (flipping the logic) or whatever, after creation: player.alive=true, simple as that. (just watch out not to “clobber” corona internal property names)
yep, more code. first thing i usually do is create some easier-to-type aliases, then get on with the ugly tests:
-- consider this pseudo-code, just to convey ideas, not to run as-is: local o1 = event.object1 -- just an alias for lazy typers local o2 = event.object2 if ((o1.name=="player" and o2.name=="enemy") or (o2.name=="player and o1.name=="enemy")) then -- ok, it's player-versus-enemy, but are they both still alive? if (o1.alive and o2.alive) then -- yep, both alive, collision needs handling.. o1.alive = false o2.alive = false -- etc else -- NOP, at least one is already dead, ignore this "late" collision end end -- much later, cleanup, in an enterFrame loop for example: if (not player.alive) then display.remove(player) -- spawn cool explosion gfx -- play awesome sound effect -- show "game over" -- etc end for each enemy if not enemy.alive then -- remove it, add score, etc end end for each bullet, similar
hth