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

2015/1/5

mirrorHorizontally() changes Image color. How to fix?

EnderPicture EnderPicture

2015/1/5

#
I am making a platformer game and I need the sprites to be flipped when it goes the other way. But when I use mirrorHorizontally(), I changes color of the sprite and made it more saturated. I do not want that. Is there a way to fix it?
davmac davmac

2015/1/5

#
Perhaps you're talking about the same problem that's discussed here? I suspect it's a Java and/or video driver bug.
danpost danpost

2015/1/5

#
You could do something like the following, which takes the right facing image and creates a left facing image from it programmatically. Then you can set the image to one of the two depending on which direction your actor is moving:
// instance fields
private GreenfootImage leftImage, rightImage;
// constructor of class (adjust actor class name)
public ActorClassName()
{
    rightImage = getImage();
    int w = rightImage.getWidth(), h = rightImage.getHeight();
    leftImage = new GreenfootImage(w, h);
    for (int y=0; y<h; y++) for (int x=1; x<=w; x++)
        leftImage.setColorAt(w-x, y, rightImage.getColorAt(x-1, y));
}
I have the same problem with 'mirrorHorizontally' changing the tint of the image. That behavior is not present using this code.
EnderPicture EnderPicture

2015/1/5

#
Running on Windows 8.1 With GreenFoot 2.4.0. http://gyazo.com/4cf93f7ab1d255929faeedb84123a248 http://gyazo.com/3ef0c9630b111660ee12440e31776cd1 I think it is the problem. How to fix it?
You need to login to post a reply.