Hi I’m new to java gaming… as will become obvious
i’m using an AffineTransform to flip my character around when i turn left, but the game then thinks the character is at different coords than it is being drawn at
i drew a white rectangle around the character, which moves with the character, but only when he is facing right
as soon as i turn him left, the rectangle mirrors about its right hand side, and then follows the character from behind, but when i turn him right again, the box flips back to
cover the character!
notice the box and the x coordinates in the images
http://www.geocities.com/petrucciboy20/1.jpg
http://www.geocities.com/petrucciboy20/2.jpg
here are some relevant parts of the 2 classes involved
if (keyCode == KeyEvent.VK_LEFT)
{
if (player.getVelocityX() < 0) return;
if (player.getVelocityX() == 0) player.setAnimation(runninganim);
if (player.getVelocityX() > 0) player.setX(player.getX()+player.getWidth());
player.setVelocityX(-0.1f);
}
public void drawTransformed(Graphics2D g)
{
if (!render) return;
AffineTransform transform = new AffineTransform();
transform.translate(Math.round(x),Math.round(y));
if (dx == 0.1f) setScale(1.0f);
if (dx == -0.1f) setScale(-1.0f);
transform.scale(scale,1);
transform.rotate(rotation,getImage().getWidth(null)/2,getImage().getHeight(null)/2);
// Apply transform to the image and draw it
g.drawImage(getImage(),transform,null);
}
thanks in advance for any hints… i know this is a big first question!