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

2016/5/19

Resizing an animated GIF

Communazi Communazi

2016/5/19

#

Animated GIFS I know it is possible to have GIFs run in Greenfoot and have done so; but i encountered a problem with resizing them. When you add the GIF actor to the world it is the desired size, but because gif are literally a series of changing images it reverts right back to it's original size when acted. I thought about trying the do an if statement for the image size but i am not sure how i would execute that. TL;DR Please explain how to resize GIFs and KEEP THEM that way. Thanks!
danpost danpost

2016/5/19

#
In the GifImage class, add the following method:
1
2
3
4
public void resizeImages(int x, int y)
{
    for (int i=0; i<images.length; i++) images[i].resize(x, y);
}
Then you can resize the images of any GifImage object you create by calling that method on it.
Communazi Communazi

2016/5/25

#
Great! Works, thank you.
Communazi Communazi

2016/6/3

#
Sorry, follow up question. in place of "images" i would use the name of the class (the class acting as a GIF)?
danpost danpost

2016/6/3

#
Communazi wrote...
Sorry, follow up question. in place of "images" i would use the name of the class (the class acting as a GIF)?
No. You would use it exactly as is. The GifImage class contains a private GreenfootImage array with the name 'images' that holds the individual images of the gif. That is what is being referred to here.
You need to login to post a reply.