I've been looking at drawing a line today. Basically I need to draw a "laser" that shoots from a "laser cannon" which can move and/or rotate. Now, in my naivity, I assumed that a single pixel scaled along x to the width required would be the way to go, but alas, when rotated, the scale multiplier remains along the x axis and does not rotate with the sprite, giving an awkward effect.
Before embarking on a lengthy mission of trial and error to find the best way, I thought I might ask around and see if anyone has done anything like this before on iOS, or if anyone with more experience can shed some light on the most optimal practice going forward.
As far as I can see, I have the following options:
1. FlxGroup - I could draw many single pixel objects along a line, throw them all in a group and then rotate that group around a fixed point. Aliasing may be a bit tricky here, but it does offer some versatility for bending the line...
2. OpenGL - I could go deep and draw the line using openGL. I only really want to do this as a last resort as this may take quite some time. Also, I will need to write a seperate collision detection algorithm for this, which won't be overly difficult. Also it would be nice to make this versatile enough that anyone could use it with a single pixel image.
3. Long-line pre-rendered - I could make a long line, and then mask the line by editing FlxSprite.width. This seems to me to be the easiest option, but probably uses the most memory.
It's my first post, so hopefully people will find this useful/intriguing.