• Create Account

### #ActualP0jahn

Posted 11 January 2013 - 07:44 PM

EDIT: Never mind, the bug was elsewhere. BeerNutts suggestion works just fine. Thanks!

### #2P0jahn

Posted 11 January 2013 - 07:38 PM

Aeramor: I have such thing implemented already. I call them "Explosion" but they have now been renamed to Particle.

BeerNutts: That sounds interesting. Tried it out, and did not work for some reason. The coordinates are wrong for some reason.

//Get the angle between the missile and the target.
float rotation = (float) getAngle(posX, posY, targetX, targetY);

//posX and posY is the location of the missile. width and realHeight is the size of the missile

float locX = posX + width / 2;
float locY = posY + realHeight / 2;

locX -= Math.cos(Math.toRadians(rotation)) * (width / 2);
locY -= Math.sin(Math.toRadians(rotation)) * (realHeight / 2);

stage.append(trailer.getClone(locX, locY));

Image img = scontrol.getImage();//The current frame of the missile(they can be animated)
img.rotate(rotation);//Rotate it
g.drawImage(img, posX, posY);//Render it
img.rotate(-rotation);//Rotate it back to normal.

### #1P0jahn

Posted 11 January 2013 - 07:33 PM

Aeramor: I have such thing implemented already. I call them "Explosion" but they have now been renamed to Particle.

BeerNutts: That sounds interesting. Tried it out, and did not work for some reason. The coordinates are wrong for some reason.

//Get the angle between the missile and the target.
float rotation = (float) getAngle(posX, posY, targetX, targetY);

float locX = posX + width / 2;
float locY = posY + realHeight / 2;

locX -= Math.cos(Math.toRadians(rotation)) * (width / 2);
locY -= Math.sin(Math.toRadians(rotation)) * (realHeight / 2);

stage.append(trailer.getClone(locX, locY));

Image img = scontrol.getImage();//The current frame of the missile(they can be animated)
img.rotate(rotation); //Rotate it
g.drawImage(img, posX, posY); //Render it
img.rotate(-rotation);//Rotate it back to normal.

PARTNERS