This site requires JavaScript, please enable it in your browser!
Greenfoot back
DogPappy
DogPappy wrote ...

2012/11/5

Actor turns rotates image

DogPappy DogPappy

2012/11/5

#
Is there a way to use the turn and rotate without actually rotating the actor's image. Or is there an easy way to reset the image to it's original state after a turn? I'd like to use the turn but keep my image the same.
erdelf erdelf

2012/11/5

#
keep a reference to the original image and set it again after each turn
danpost danpost

2012/11/5

#
turn(n);
getImage.rotate(-n);
should work (as long as your image fits within a circle inside the frame of the image).
davmac davmac

2012/11/6

#
The best way is to maintain your desired rotation in a separate variable, and always keep (or reset) the real rotation to 0. So for instance, if you want to move, you can:
setRotation(myRotation);
move(10);
setRotation(0);
You can, if you want, override the turn and move methods with your own version that do this automatically:
public void move(int distance)
{
    setRotation(myRotation);
    super.move(distance);
    setRotation(0);    
}
DogPappy DogPappy

2012/11/7

#
Thanks for the info, I will try it out.
You need to login to post a reply.