You must login or register to participate.

Description

Learn Java, the language of the internet!  No prior experience required!

To get started, JOIN THIS GROUP. Then click on the Activities tab. Next complete each of the Activities. And finally compete in the Challenge Activity.

Click the Details tab for more information. After you've completed this path, if you've enjoyed it and want to go further, check out some of the other programming learning paths, including Make a 3D Video Game and Building Flashy Websites with JavaFX.

Learning Path and Challenge Activity Provided By

FreshBrain is proud to sponsor the "Learn Java Programming" learning path and challenge activity.

More Fun - Let's Get Animated

 More Fun - Let's Get Animated

Description

Now that we know how to take advantage of Greenfoot support classes, let's look  at a specific class for an animated Actor.  In this activity you will:

  • Create a new class AnimatedActor by reusing the Greenfoot Support Class.
  • Create a subclass of AnimatedActor, AnimatedMonster and show how to use its features.
  • For those with artistic talent, you can replace the images provided with those of your own to create your own animated image.
  • Run the scenario to see how the animation looks.

Skills you will learn include:

  • Basics about a simple form of animation. This will serve as a basis before getting into more complicated approaches to animation.
  • Programming constructs including arrays and string concatenation.

Basic Steps

  1. Start up Greenfoot.
  2. From the Scenario menu, select the scenario called Monsters.
  3. Next, create a subclass of Mover called AnimatedActor. Open the editor and cut and paste this code for the AnimatedActor class. You can learn more about AnimatedActor and other Greenfoot Support Classes in the Greenfoot Programmer's Manual and Greenfoot Support Classes.  We will also go through the the code for this class in Digging Deeper.
  4. Create a subclass of AnimatedActor.  We’ll call it AnimatedMonster.  Pick an image to represent the new class.
  5. Open the editor for AnimatedMonster. Edit AnimatedMonster, adding a constructor, AnimatedMonster() and  and the method called act().  The code for AnimatedMonster() and act can be found here.  In our example, we have 4 .png images. They start with “animon”.  That is, animon0.png, animon1.png, animon2.png, animon3.png.
  6. Compile, add AnimatedMonster objects and run the scenario.  You will notice that rather than moving across their world, AnimatedMonsters stay in one position, but move or change in place.  Figure out how to add code to have your monster move across the world while continuing to animate.  Make sure they respond to the left and right arrow keys.  Hint: Steal some code from a previous activity.
  7. Compile and add AnimatedMonsters to your world.  If your updates are correct, you should notice that now the monsters animate while moving.  Make sure they also respond to the left and right arrow keys.
  8. Read Greenfoot Support Classes: Digging Deeper on AnimatedActor  to learn about Greenfoot support classes and the AnimatedActor class.
  9. Please read the following instructions for preparing your work prior to submission to this activity.
  10. Select Scenario -> Export.  Choose  Webpage (from Publish, Webpage, Application) and select a location to save the scenario as an applet (a jar file and a .html file).
  11. Submit the exported jar file for this activity.

Suggested Activity Tools

Resource Links

Recent Submissions

icon

Activity 7

0
August 8, 2009 by sunshinehombre
icon

Last Activity!!

0
August 1, 2009 by artjunkie360
icon

Animated Monster !

0
July 28, 2009 by Mozky
icon

Monster 4

0
August 16, 2009 by Ryanh423
icon

Animated Monsters

0
August 3, 2009 by zackiddy
icon

The Animated Blob

0
July 22, 2009 by dman0875
icon

000

0
July 12, 2009 by Mazin
More Submissions

Activity Forum

Topic
Replies
Posted
Last Reply
3
Jul 13, 2009
by MonkeyWarlock
35 weeks 1 day ago