Hi, I want to create a mirror image effect: when the character is moving left it face left, when is moving right it face right.
The character can move also up and down, but I want only this kind of effect: left and right.
So, if my character have face left and it move up/down, it continues with face left
if the character hava face right and it move up/down, it continues with face right
this is the code:
public void draw(Graphics2D g) {
AffineTransform transform = new AffineTransform();
// translate the sprite
transform.setToTranslation(x,y);
// if the sprite is moving left, flip the image
if (dir == dir.WEST) {
transform.scale(-1, 1);
transform.translate(-sprite.getWidth(), 0);
}
g.drawImage(sprite.image,transform,null);
}
The problem is: 'cause my default image have face right, if it move left, it change to face left, but if it move up/down/right, it change to face right.
for example: character is moving left, it change to face left… then, character is moving up/down, it change to face right.
How I can resolve this problem??