Animating Actors In Greenfoot

7
Animating Actors Animating Actors In Greenfoot In Greenfoot

description

Animating Actors In Greenfoot. To create an animated actor, you must first: Create a series of images. The images must begin with the same name FOLLOWED by the number for which order you want the images animated. For example:. - PowerPoint PPT Presentation

Transcript of Animating Actors In Greenfoot

Page 1: Animating Actors  In Greenfoot

Animating Actors Animating Actors

In GreenfootIn Greenfoot

Page 2: Animating Actors  In Greenfoot

To create an animated actor, you To create an animated actor, you must first:must first: Create a series of images.Create a series of images. The images must begin with the same The images must begin with the same

name FOLLOWED by the number for name FOLLOWED by the number for which order you want the images which order you want the images animated.animated.

For example:For example:

Page 3: Animating Actors  In Greenfoot

Once you have your images, you Once you have your images, you must place them in the “images” must place them in the “images” folder of your scenario.folder of your scenario.

You will then need to create You will then need to create subclasses of your Actor class.subclasses of your Actor class. Create a Mover class Create a Mover class The support file The support file

is on the Greenfoot website.is on the Greenfoot website. Create an AnimatedActor class Create an AnimatedActor class The The

support file is on the Greenfoot website.support file is on the Greenfoot website.

Page 4: Animating Actors  In Greenfoot
Page 5: Animating Actors  In Greenfoot

You must copy the code from those You must copy the code from those support classes into the code for the support classes into the code for the Mover and AnimatedActor classes.Mover and AnimatedActor classes.

After you do this add your class you After you do this add your class you wish to animate as a subclass to the wish to animate as a subclass to the AnimatedActor class. Ex:AnimatedActor class. Ex:

Page 6: Animating Actors  In Greenfoot

Add the following code to your class:Add the following code to your class: Ex:Ex:

This is the first part of the name of your image files.

This is the filename extension of your files.

This is the number of files you are animating.

Page 7: Animating Actors  In Greenfoot

What does “super” What does “super” mean?mean? Super calls the Super calls the

superclass’ superclass’ constructor.constructor.

Also, the super Also, the super keyword gives you keyword gives you access to the access to the superclass’ methods superclass’ methods and variables.and variables.

In this example, In this example, AnimatedActor is AnimatedActor is the superclass of the the superclass of the Bullet class.Bullet class.

public class Bullet extends AnimatedActor{ public Bullet( ) { super("bullet", ".png", 3); }

public void act( ) { super.act( ); }}