0
 AffineTransform tx = new AffineTransform();
    tx.translate(0, 100);
    tx.rotate(233);
    tx.setToRotation(34, 333, 333, 222);
        g.drawImage(player_image, x, y, x+width, y+height, 
            50*(int)frame, 147, 50*(int)frame+50, 189 ,Sprite_Sheet.m1);

not sure what iam doing wrong. this code below just display image

 g.drawImage(player_image, x, y, x+width, y+height, 
        50*(int)frame, 147, 50*(int)frame+50, 189 ,Sprite_Sheet.m1);

now how can i flip it verical?

2
Contributors
3
Replies
4
Views
4 Years
Discussion Span
Last Post by JamesCherrill
0

It looks like you created the transform OK, but missed the bit where you associate the AffineTransform with Graphics, as in g.transform(tx);, before drawing.
Once you have that working you will be able to see how different transforms affect your image. I suggest just starting with one at a time, and don't forget scale with a negative value to flip an image.

0

ah ok i begning to see how AffineTransform works

((Graphics2D) g).setTransform(tx);
g.drawImage(player_image, x, y, x+width, y+height, 
            50*(int)frame, 147, 50*(int)frame+50, 189 ,Sprite_Sheet.m1);

this seem to be working but the thing is. i have alot of g.drawImage in side method. but i only want to filp one image. for some reason ths filps the more images.

0

you can change the transform you are using, do some drawing, change it, do some more etc
You can also get the Graphic's original transform, save it in a var, then restore it after doing some flipped drawing

Edited by JamesCherrill

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.