Hi all,
im new to this forum so please forgive me that im starting off asking questions to you guys.
Im currently working on a real-time strategy game for android and im making quite some progress. The graphics (units, bases, etc.) are animated 2d sprites and it all seems to work pretty well so far.
But now i have encountered a problem to which i'm aparently unable to find any good (performant) solution.
The problem is, that i want to add shooting animation to the game. A firing unit is pretty easy, but let's say for example, that i have a spaceship that fires a laser beam towards its target. The beam should be animated and of course can be of variable length, as units usually have a specific firing range in which they can hit a target.
So its pretty much impossible to use a specific animated sprite for that beam, as it would be of a constant length.
My first idea was to create animated beam-segments which i put together to create beams of variable length. Depending on the length of those segments, this can be pretty bad in terms of performance if (for example) i had to draw a laser beam of very long length, which would result in a lot of textured triangle fans i would have to render.
My next idea was to first determine the length of the beam i would have to render, on a next step i would create a bitmap of that specific length and draw the beam segments in that bitmap. Then of course i would create a texture with that bitmap and draw it upon a triangle fan. BUT, as those beams are animated, this solution as well seems to be pretty bad in terms of performance.
I think, that the best solution for now would be my first idea, using beam segments of, lets say 8-16 pixels in length. This would cause the beams to be slightly too long or too short, but i think for now thats really my best bet.
Or does anyone have any ideas on how to solve that particular problem in a better way?
Thanks in advance.


