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

2012/5/8

How to flip an image ONCE

freddekl freddekl

2012/5/8

#
I am currently tring to get my actor which is a stick figure with a weapon to move left and right and face those directions while walking, when I turn left he turns upside down. I tried getImage().mirrorHorizontally() but it just made my actor flip constantly. I also tried doing
if("left".equals(Greenfoot.getKey())  
{  
    getImage().mirrorVertically();    
}  
but that made my actor turn when I released left, which means I moved to the right and then turned to face left when I released left, and it wouldn't return back to right either, it just stayed with left. So what I want to do is an actor that moves to the left and right and faces that direction (not being upside down). Can anyone help me?
SPower SPower

2012/5/8

#
before you mirror it, you need to set the image to the image you want to mirror. So if you want to mirror the image when you go to the right position, set your image for the left position, and then mirror it.
freddekl freddekl

2012/5/8

#
thanks :D I got it now.
You need to login to post a reply.