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

Report as inappropriate.

danpost
danpost presents ...

2016/7/11

GifImage vs Animation

This scenario demonstrates some of the differences between the GifImage class (supplied by greenfoot) and the Animation class (by danpost). I made use of the GifImage class to decode the 'gif' image file to get the images for the Animation class just to show how that can be done.

Visual differences:

* GifImage object "continues" (without updating) to run while the scenario is stopped while Animation object starts and stops with the scenario;
-test by clicking 'Pause/Run' button -- GifImage object may "jump" to a frame while Animation object does not;

* GifImage objects may jump frames when the scenario speed is dramatically reduced and the frame rate remains constant when the scenario speed is otherwise altered; Animation objects alter their speed dependent on the scenario speed;
-test by changing the speed of the scenario with the speed slider;

Non-visual differences:

* the GifImage class can display frames for different amounts of time (which, by the way, is determined by the 'gif' file and cannot be changed) while all frames will be displayed about the same amount of time by the Animation class;

* a GifImage object must be created for each animation image set while an Animation object has a changeable image set;

* a GifImage object just holds the image set and frame times and informs the object using it what image to use when asked; an Animation object is assigned an object and updates the image of the object when necessary (under the control of that object);

4675 views / 9 in the last 7 days

4 votes | 0 in the last 7 days

Tags: demo with-source test danpost gifimage

This scenario is a member of: Demos by danpost


open in greenfoot
Your browser is ignoring the <APPLET> tag.
HTML5 version not available | Scenario not running?
A new version of this scenario was uploaded on 2016-07-11 21:05:47 UTC
A new version of this scenario was uploaded on 2016-07-11 21:32:16 UTC Source available.
A new version of this scenario was uploaded on 2016-07-11 21:33:36 UTC Source available. Side by side comparison of classes.
A new version of this scenario was uploaded on 2016-07-12 04:03:05 UTC
nizatenizate

2017/7/25

Downloaded, says there it can not be compiled. Error lastBGColor first line and c on the 3rd line (In this comment not in the code): c = new Color(lastBgColor); // use given background color } g.setColor(c);
nizatenizate

2017/7/25

in setPixels() method.

Want to leave a comment? You must first log in.

Who likes this?

lehrerfreund chiconese trimil Game/maniac