|
Here's a listing of this simple class:
// SeasideStage.java
import linguist.quickshow.*;
public class SeasideStage extends Stage
{
public void setupStage()
{
setStageSize(WIDTH,HEIGHT);
show();
new Beach(this);
new Ball(this,0);
new Ball(this,1);
}
public final int WIDTH=300;
public final int HEIGHT=156;
}
The SeasideStage, a subclass of Stage, has only one method, setupStage(),
which is called when the component starts. As a general rule, this method should do the following:
- Set the size of the Stage
- Make the Stage visible in its container
- Call in the Actors
The Actors are instantiated one by one. Everything visible must be an Actor, including
the backdrop, and should be declared in Z-order, from back to front. There is (limited) support for layering, allowing
you to place one Actor behind another or move them forward and back in the hierarchy.
There's usually no need to save a reference to an Actor for later use; any Actor can be found by giving its
name to a search function.
Once the setting up is done the Stage takes no further obvious interest in proceedings, but sits in the background
quietly managing the system.
|