Hi, it's the first time I am in this situation and I am not sure if my approach is the right one:
I have some guys roaming across the stage, who are being targeted by turrets as in any tower defence game.
A bit of overall lag when they're many would be acceptable, but at some point I lose control of their "status" (like burn, or freeze).
I suppose due to the lag because when they are only a few it's not an issue.
I tried keeping everything simple:
almost everything is handled by a single enterframe function in the level file, that sets a "tick" each second (frame based) and changes values.
Later in the same function those values are read, and with a bunch of conditions based on these values things happen.
I am now playing with profiler to lighten the heaviest functions, but I think I used all the tricks I know: from localizing anything to loading the fewest texturepacks.
I still see some potential by pooling status sprites (everything else is already in a pool) but I am not sure it would be enough.
To make a practical example: every actor has a property to define its status, which is a table made by 2 entries: the first one is a counter that starts from 0 and is increased on every new "tick", the second one is the limit it should reach before annihilation (this is also handled by the same function that increase it)
Pseudocode goes like this:
--increase status time
if actor.status<=actor.status then
actor.status = actor.status+1
actor.status = nil
--remove graphics relative to status
if actor.status == nil then
actor.statusSprite = nil
--apply status damage
actor.hp = actor.hp -1
-- ... and so on for almost anything
What I don't understand is how is it possible that some lines of code are executed, while others seems to be skipped: I mean, even if I lose "tick number 34", shouldn't this thing be executed on "tick number 35" and following "ticks"?
So why there is a random condition when I still see flames on a guy who doesn't get any damage from them and they won't ever disappear?
I may avoid adding flames as a new movieClip, but if I have to draw any guy in flames in 3 frames I would exponentially increase the number of textures I need to load...