Report as inappropriate.
A simple class to aid in animating the image of Actor objects or the background image of World objects.
(1) Add a field to the World or Actor subclass to hold an Animation object;
(2) build an array of GreenfootImage objects to be used in the animation (frame images);
(3) create and assign a new Animation object to the field declared in (1) above;
(4) set the cycle time (see 'cycleActs' field and related methods);
(5) activate the Animation object (see the 'activeState' field and related methods);
(6) run the animation from the act method of the class (see the 'run' method);
Arrow keys regulate the speed of the animations:
'up/down' controls Actor object animation time
'left/right' controls World object animation time
The higher (or longer) the time, the slower the animation; lower times yeild faster animations.
Press 'd' to reverse the images in the World background animation (the animation will appear to run backward).
Press '0', '1', '2' and '3' to change the animation image set for the Actor object. The '1' image set will execute 6 cycles and then the image set will change back to the '0' set automatically.
Click on Actor object to remove it from the world.
4027 views / 906 in the last 7 days
3 votes | 0 in the last 7 days
This scenario is a member of: Support Classes by danpost
To embed this scenario in a web page, copy the following HTML code:
Want to leave a comment? You must first log in.