So I have created a general class that allows an image to be animated and to "vertically lock" rotation, so that when you move it only rotates left and right, not up and down. (This is the equivalent of the left-right rotation style in Scratch).
I'm acquiring a "newImage" from an array of image names, and rotating the image in the opposite direction of the rotation of the actor, like this:
And it works, except, when I rotate the image from the vertical or horizontal direction, it chops it off like this:
I get that the problem is that it's rotating the image but not changing the image height and width. But not sure what the fix is. Any ideas>
1 2 3 4 5 6 | GreenfootImage newImage = new GreenfootImage(imageNames[currentImage]); int rot = theActor.getRotation(); if (rot> 0 ) newImage.rotate(-rot); //some other stuff to rotate left-right theActor.setImage(newImage); |
