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?

Recommended Answers

All 3 Replies

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.