When I call the method rotate() for an image: img.rotate(rotation); it rotated the image but also changed the image's white spots to pink is there something I am doing wrong? This also happens with the img.mirrorHorizontally();
public void drawCharacter(int factor)
{
int rotation = 0,rotation2 = 0;
String up = "Up";
rotation2 = (int)(90 - -accelX * 9) * 2 - 90;
if(accelX > 0)
{
mirror = true;
rotation2 += 180;
rotation = ((int)accelY * 5);
}
else if(accelX < 0)
{
mirror = false;
rotation = ((int)-accelY * 5);
}
if(rotation2 - 180 > -45 || rotation2 < 45)
{
up = "";
if(accelX > 0)
{
rotation2 += 90;
}
else
{
rotation2 -= 90 + 180;
}
}
GreenfootImage img = new GreenfootImage("characterSwim"+up+"-"+(characterCostume+1)+".png");
if(mirror)
{
img.mirrorHorizontally();
}
img.scale(img.getWidth() * factor,img.getHeight() * factor);
img.rotate(rotation + rotation2 - 90);
screen.drawImage(img,300 - img.getWidth() / 2,300 - img.getHeight() / 2);
}public GreenfootImage flip(GreenfootImage img)
{
GreenfootImage img2 = new GreenfootImage(img.getWidth(),img.getHeight());
int x = 0;
while(x < img.getWidth())
{
GreenfootImage save = new GreenfootImage(1,img.getHeight());
save.drawImage(img,-x,0);
img2.drawImage(save,img.getWidth() - x,0);
x++;
}
return img2;
}