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?

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.

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.

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 4 Years Ago by JamesCherrill

This article has been dead for over six months. Start a new discussion instead.