Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Rotating Images in Java

Options
  • 13-04-2006 9:01pm
    #1
    Registered Users Posts: 700 ✭✭✭


    I'm trying to trying to rotate an Image in java without any luck.

    It's for a J2ME game and I've looked at the Image Api and cannot find any Image.rotate() methods!!

    Anyone out there know how to rotate images. Also, seeing as they will appear on a Canvas, ImageIcons won't work... (I think):confused:


Comments

  • Closed Accounts Posts: 261 ✭✭bishopLEN


    Is the image a sprite or have you added it to a layer ? or something different ?
    I will have a look and try with the scenario you have.


  • Closed Accounts Posts: 1,152 ✭✭✭sound_wave


    Don't know if this is any use to you:

    http://forum.java.sun.com/thread.jspa?threadID=382997&messageID=1643308

    Hope that is something along the lines of what you were looking for, or at least helps in some way.


  • Registered Users Posts: 700 ✭✭✭Magown3


    bishopLEN wrote:
    Is the image a sprite or have you added it to a layer ? or something different ?
    I will have a look and try with the scenario you have.

    bishopLEN,

    Yes they are Sprites. I've also written my own Sprite Class. Here's some of my code:
    private Image blueAtom, redAtom;
    ...
    blueAtom	 = Image.createImage ("/res/cars/subaruImpreza.png");
    ...
    //public Sprite (Image img, int xPos, int yPos, int xVel, int yVel, int z, int wBnds, int hBnds, int ba)
    localSprite  = new Sprite (blueAtom, localX,  localY,  0, 0, 0, getWidth (), getHeight (), Sprite.BA_BOUNCE);
    

    I've had a look at this but it's quite jumpy and unrealistic. Any way to improve this?

    sound_wave,
    I actually had a look at that page just before I posted here but I think that it's rotating the entire JPanel. But I like the way it's so smooth... it looks good :)


  • Closed Accounts Posts: 261 ✭✭bishopLEN


    I presume you tried the sprite setTranform() method...

    Also are you using MIDP1.1 or 2.0 ?


  • Registered Users Posts: 700 ✭✭✭Magown3


    bishopLEN wrote:
    I presume you tried the sprite setTranform() method...

    Also are you using MIDP1.1 or 2.0 ?

    Yea I'm using MIDP 2.0 and a Nokia 6600.


  • Advertisement
Advertisement