| Reply | « Previous Thread | Next Thread » |
|
I can easily rotate my image at coords 0,0 but what if I want to rotate at coords 16,0?
I tried the following... dg.drawImage(myImage, x - (frame*frameWidth), y, dg.TOP|g.LEFT, 90); .. but this performs the rotation first then does the translation. Thanks. |
|
Instead of this
dg.drawImage(myImage, x - (frame*frameWidth), y, dg.TOP|g.LEFT, 90); Try this if it can solve your problem dg.drawImage(myImage, x - (frame*frameWidth), y, g.TOP|g.LEFT, DirectGraphics.ROTATE_90); |
|
Hi,
I tried your suggestion but this has the same effect. For example, if myImage consists of two 16*16 frames: one at 0,0 and the other at 16,0. The drawImage function seems to rotate the whole image(both frames) first so the frame that was at 16,0 is no longer there because of the 90 degree counter-clockwise rotation. |
|
I think it only ever rotates the image, it doesn't translate then rotate about a point. If thats what your trying to do.
you'd have to write your own code to do that i imagine, plus your limited to 90 degree rotations with directgraphics. |
| EvilCartman |
| View Public Profile |
| Find all posts by EvilCartman |
|
Of course it rotates the whole image. It doesn't know that it is composed of frames. So the code is really just doing what you ask of it.
You have 2 choices: 1) Break the frames up so that each one is in it's own image. 2) Take the fact that the whole image is rotated into consideration when you draw it: Code:
// after the rotation the second frame is at (0,16) // and not at (16,0), so you have to offset the // y coordinate instead of the x dg.drawImage(myImage, x, y - (frame*frameWidth), g.TOP|g.LEFT, DirectGraphics.ROTATE_90); [edit] Another thing to consider is that if you rotate 180 or 270 degrees the order of the frames will be reversed, so you're offset would be ((totalFrames - frame) * frameWidth). [/edit] |
|
Thanks shmoove.
Option 2 worked a treat! |
|
Does anyone know if the MIDP 2.0 drawRegion() method works in a similar way? Does it rotate the whole image or just the region that you are trying to draw?
|
|
It does rotate the complete image.
|
|
Actually I've figured it out since then - drawRegion just seems to rotate the region of the image that you specify! It must select the region of the image first and then just rotate that part.
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|