Listing 1
1 public void animationTest() {
2
3 // Enter full-screen mode
4 // and start animation
5 GraphicsSource.enterDisplayMode(
640, 480);
6 GraphicsSource.setRenderListener(
this);
7 GraphicsSource.startAnimation(60);
8
9 // wait for it to complete
...
10
11 // Stop animation
12 // and exit full-screen mode
13 GraphicsSource.stopAnimation();
14 GraphicsSource.exitDisplayMode();
15 }
16
17
public void init(
boolean
isPageFlipping,
int bufferWidth,
int bufferHeight) {
18
19 // Load the background image
20 // and foreground sprite
21 background = ImageSource.getImage(
"background.gif");
22 fighter = ImageSource.getImage(
"fighter.gif");
23 }
24
25
public void updateModel() {
26 // update position of fighter
27 // and background ...
28 }
39
30
public void render(Graphics g,
boolean
isBufferCleared,
int bufferIndex)
{
31
32 // Draw the animation frame
33 g.drawImage(
background,
xb, yb, null);
34 g.drawImage(fighter, xf, yf, null);
35 }