PulpCore

pulpcore.scene
Class Scene

java.lang.Object
  extended by pulpcore.scene.Scene
Direct Known Subclasses:
Scene2D

public abstract class Scene
extends Object

A Scene is an object that updates the display and handles input from the user. All PulpCore apps will implement a Scene.

A typical game will have several Scenes: for example, a title scene, menu scene, main game scene, high score scene, help scene, etc.

For Applets, the first Scene is defined by the "scene" applet parameter:

<param name="scene" value="MyFirstScene" />

The Stage is responsible for invoking the Scene's methods, with the exception of reload().

See Also:
Stage.setScene(Scene), Stage.replaceScene(Scene), Stage.pushScene(Scene), Stage.popScene()

Constructor Summary
Scene()
           
 
Method Summary
abstract  void drawScene(CoreGraphics g)
          Draws to the surface's graphics context.
 void hideNotify()
          Notifies that this scene has been hidden by another Scene or immediately before a call to stop().
 void load()
          Performs any actions needed to load this scene.
 void redrawNotify()
          Notifies that this scene that the Stage or the OS has requested a full redraw.
 void reload()
          Reloads the scene.
 void showNotify()
          Notifies that this scene has been shown after another Scene is hidden or immediately after a call to start().
 void unload()
          Performs any actions needed to unload this scene.
abstract  void updateScene(int elapsedTime)
          Updates the scene.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Scene

public Scene()
Method Detail

load

public void load()
Performs any actions needed to load this scene. By default, this method does nothing. Typical implementations will load images and sounds in this method.


unload

public void unload()
Performs any actions needed to unload this scene. By default, this method does nothing. This method should return as quickly as possible; if unloading a scene requires a long computation, it should be done in a separate thread.


reload

public void reload()
Reloads the scene. This method calls unload() followed by load().


showNotify

public void showNotify()
Notifies that this scene has been shown after another Scene is hidden or immediately after a call to start(). Note, this method is not called if the OS shows the app. By default, this method does nothing.


hideNotify

public void hideNotify()
Notifies that this scene has been hidden by another Scene or immediately before a call to stop(). Note, this method is not called if the OS hides the app. By default, this method does nothing.


redrawNotify

public void redrawNotify()
Notifies that this scene that the Stage or the OS has requested a full redraw. By default, this method does nothing.


updateScene

public abstract void updateScene(int elapsedTime)
Updates the scene. This method is periodically called by the Stage while this Scene is active. A scene will typically update sprites and handle input.

When a Scene is first shown (after a call to showNotify), the elapsedTime is zero.

The Stage starts a synchronized block on this Scene before calling this method and ends the block after drawScene(CoreGraphics) returns.

Parameters:
elapsedTime - time, in milliseconds, since the last call to updateScene().

drawScene

public abstract void drawScene(CoreGraphics g)
Draws to the surface's graphics context. The Stage calls this method after calling updateScene(int).

The Stage starts a synchronized block on this Scene before calling updateScene(int) and ends the block after this method returns.

Parameters:
g - the CoreGraphics object to draw to. The CoreGraphics clip is set to the entire display area.

PulpCore

Copyright © 2007-2009 Interactive Pulp, LLC.