I bet you can make a pretty funky laser beam using the draw lines or fill polygon commands in the Canvas/Paint library.
To draw basic unpulsed laser beam draw a transparent line of width 6 between a and b. Then draw on top an opaque line of width 2 between a and b. You will get an effect where the laser beam falls off in brighness from the centre to the edges. To pulse it, draw a short line segment of width (say) 8 on top of the unpulsed laser beam, and move its position between a and b every screen refresh so the pulse moves along the line. If you want your laser beam to be some shape other than a long thin rectangle, you can do the same thing with a polygon fill command and you can have the laser beam whatever shape and size you want. On Feb 3, 7:38 pm, Mando <[email protected]> wrote: > Hi, hope this is the right location to post this. > > I am working on a 2d android game with a light space shooter theme. I > wanted my ship to have a turret the that tracks targets, rotates and > fires a laser beam that is animated (maybe pulsing or with non uniform > bulges issuing out of the turret and moving down towards the target). > > Key parts of the problem. laser starts at 1 coordinate and terminates > at another in 2d space and could be of arbitrary length (might be > scaled if I decide to add zooming). > > Possible brute force solutions: > 1) using rotation/transformation to manually draw a bitmap > representing a segment of laser all along the required distance. > (cycling the bitmap as required for animation) > 2) Create a very large laser beam image (longer than I would need eg: > 10px by 500px) and draw it at correct transformation. > > Looking at the BitmapShader and reading some of the SDK info about > Paths, Paints etc it feels like there should be a better way to do > this, but no examples I've found covers it. > > Any idea if there is a way to use a BitmapShader to paint using a > canvas.drawLine or canvas.drawPath call to create this effect? > > Thanks in advance > > Mando -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

