I am in process of writing my own laser drawing function. Does not looks as good as Laser FX, but performs better.
I have ran into a math problem and hope someone here can help me.
Have a look at the following image:
The laser is set to fire at a certain point(the top-left corner of the red guy), which it actually does. The top-left, or the bottom-left(not sure which one) corner of the laser beam is exactly at the target coordinate.
What I want to do is to have the lasers middle point at the target point, not the corner.
Here is my code, I am using the following method to draw the laser:
SpriteBatch.draw(TextureRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation)
float angle = MathStuff.getAngle(srcX, srcY, destX, destY);
batch.draw(beamImage, srcX, srcY, 0, 0, MathStuff.distance(srcX, srcY, destX, destY), beamImage.getHeight(), 1, 1, angle);