Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Rotating Images in Java

  • 13-04-2006 09:01PM
    #1
    Registered Users, Registered Users 2 Posts: 714 ✭✭✭


    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, Registered Users 2 Posts: 714 ✭✭✭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, Registered Users 2 Posts: 714 ✭✭✭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