AnimationWorld -- Animation Players

Animation Players are used to play the animation. There is an AnimationPlayer GUI component which is added to applets. The space which this component takes on the applet is known as the "screen size". The animation is projected onto this screen. If the animation frame size is unspecified, the animation is projected to fill the screen. If the animation frame size is smaller than the screen size, the animation is centered on the screen. If the animation frame size is bigger than the screen size, only the top left corner of the animation frame that fits on the screen will be shown. The default screen color is black (as opposed to the default frame color which is white). Therefore, if the animation frame is smaller than the screen, it will be bordered by the screen color.

To play our animations, we just extend a preexisting AnimationPlayer implementation. Two animation players are currently available.

The two players above work in identical ways. There are five buttons in the interface: The textfield displays the current frame number and is used for entering desired frame numbers. Note that the textfield does not seem to be editable under the Symantec appletviewer, but it does work on PCs and in Netscape on a Mac (haven't tried it elsewhere).

To create an Animation Player for our animation, we extend one of the two players above, and implement a default constructor method. In the constructor we create an instance of our animations and add them to the player via the addAnimation(String name, Animation a) method. The SimpleAnimationPlayer will ignore all animations added but the first one. The choice list for the AnimationShowcase will be in the order that animations are added to the player. The name is required and is displayed in the interface.

The following methods may also be used to configure the appearance of the animation player. All methods are available for both players.

The following methods may be used to configure when the animation plays automatically. By default, animations are not played until users hit the PLAY button. Animations automatically stop when the user leaves the web page (goes to another web page) or when the web browser window loses focus.

Examples

The example code demonstrates most of the features above. Clicking on the link will open up a new web browser window with the player so you can see what the player looks like. Each player below would be defined in its own file named after the name of the animation player class.

BuggleAnimationPlayer1
Extending the SimpleAnimationPlayer

public class BuggleAnimationPlayer1 extends SimpleAnimationPlayer {
  
  public BuggleAnimationPlayer1 () {
    addAnimation("RightBuggle", new BuggleAnimation1());
  }
  
}
BuggleAnimationPlayer2
Extending the SimpleAnimationPlayer again. Can put any animation in the player with any name.
public class BuggleAnimationPlayer2 extends SimpleAnimationPlayer {
  
  public BuggleAnimationPlayer2 () {
    addAnimation("RightLeftBuggle", new BuggleAnimation2());
  }
  
}
BuggleAnimationPlayer3
Setting the animation player to play the animation every time the web page is loaded.
public class BuggleAnimationPlayer3 extends SimpleAnimationPlayer {
  
  public BuggleAnimationPlayer3 () {
    setPlayOnStart();
    addAnimation("SpyBuggle", new BuggleAnimation3());
  }
  
}
BuggleAnimationPlayer4
Setting the animation player to play the animation every time the applet is painted. Set the screen color.
public class BuggleAnimationPlayer4 extends SimpleAnimationPlayer {
  
  public BuggleAnimationPlayer4 () {
    setScreenColor(new Color(128,0,0)); // maroon
    setPlayOnPaint();
    addAnimation("SpyArmy", new BuggleAnimation4());
  }
  
}
BuggleAnimationPlayer5
Placing animation on page with no buttons or labels. Animation is played each time the web page is loaded.
public class BuggleAnimationPlayer5 extends SimpleAnimationPlayer {
  
  public BuggleAnimationPlayer5 () {
    hideControlPanel();
    setPlayOnStart();
    addAnimation("SpyArmyII", new BuggleAnimation5());
  }
  
}
BuggleAnimationPlayer6
Placing animation on page with no buttons or labels. Animation is played each time web browser window gets focus or user scrolls to show applet.
import java.awt.*; // use colors

public class BuggleAnimationPlayer6 extends SimpleAnimationPlayer {
  
  public BuggleAnimationPlayer6 () {
    hideControlPanel();
    setPlayOnPaint();
    addAnimation("SpyArmyIII", new BuggleAnimation5(Color.green,Color.blue,Color.red,Color.cyan,Color.magenta));
  }
  
}
BugglesInAndOut
Extension of SimpleAnimationPlayer with only three buttons: RESET, PLAY, and STOP.
public class BugglesInAndOut extends SimpleAnimationPlayer {
  
  public BugglesInAndOut () {
    hideNextButton();
    hideGotoButton();
    hideFrameNumberDisplay();
    addAnimation("BugglesInAndOut", new BuggleAnimation6());
  }
  
}
BuggleShowcase
Extension of AnimationShowcase with all the animations above. Animations are set to play when selected.
import java.awt.*; // use colors

public class BuggleShowcase extends AnimationShowcase {
  
  public BuggleShowcase () {
    setPlayOnSelection();
    addAnimation("RightBuggle", new BuggleAnimation1());
    addAnimation("RightLeftBuggle", new BuggleAnimation2());
    addAnimation("SpyBuggle", new BuggleAnimation3());
    addAnimation("SpyArmy", new BuggleAnimation4());
    addAnimation("SpyArmyII", new BuggleAnimation5());
    addAnimation("SpyArmyIII", new BuggleAnimation5(Color.green,Color.blue,Color.red,Color.cyan,Color.magenta));
    addAnimation("Buggles In and Out", new BuggleAnimation6());
  }
  
}

AnimationWorld
Sprites
Animations
Animation Players
HTML pages