Represents a single scene in a game. If you view the whole game as a play, the terms for
Stage
and Scene will make complete sense, as they are intentionally named this way in
the framework. A game can have several scenes based on its nature. For example, a simple game
consists of a menu scene, a game scene and a game over scene where scores and rankings are shown.
Scenes methods provide the means to manipulate stage properties and navigate between scenes. public class Scene implements Touchable
Field Summary
Modifier and Type | Field and Description |
---|---|
protected | stage Holds the parent stage for this scene. |
Constructor Summary
Modifier and Type | Constructor and Description |
---|---|
public | Scene(Stage parentStage) Creates a new scene belonging to the given Stage. |
Method Summary
Modifier and Type | Method and Description |
---|---|
public void | add(Entity entity) Adds an entity to the scene. |
public void | advance(float elapsedTime) Advances the animation for this scene. |
public final RGB | getBackColor() Gets the background color for this scene. |
public final Dialog | getDialog() Gets the current dialog that is currently showing on the scene. |
public final PhysicsSimulator | getPhysicsSimulator() Gets the default physics simulator for this Scene. |
public final Stage | getStage() Gets the stage that this scene is displayed on. |
public final TouchMap | getTouchMap() |
public final void | halt() Halts the scene. |
public void | handleInput(GameInput inputManager) Handles input for this scene. |
public boolean | handleTouch(TouchEvent event) Called whenever a touch event arrives. |
public final boolean | isHalted() Indicates whether the scene is currently halted. |
public final boolean | isLoaded() Indicates whether the resources for this scene are loaded. |
public boolean | onBackButton() Handles the back button event. |
protected void | onDialogDismissed(Dialog dialog) Called by the framework whenever a dialog is dismissed from the scene. |
protected void | onHalted() Called by the framework after this scene goes to a halted state. |
public void | onLoaded() Called by the framework when all resources for the scene are safely in place. |
public void | onLocalLoad() Called by the framework to load scene-local resources. |
protected void | onUnhalted(float delay) Called by the framework after this scene goes out of a halted state. |
public final void | remove(Entity entity) Removes an entity from the scene. |
public final void | render(RenderingContext context) Renders the scene on the given OpenGL context. |
public final void | setBackColor(RGB color) Sets the background color for this scene. |
public final void | setBackColor(float r, float g, float b) Sets the background color for this scene. |
public final void | unhalt() Un-halts a previously halted scene. |
Methods inherited from java.lang.Object
clone
, equals
, finalize
, getClass
, hashCode
, notify
, notifyAll
, toString
, wait
, wait
, wait
Field Detail
stage |
---|
protected stage Holds the parent stage for this scene. You MUST NOT modify the value of this field from
within subclasses, as this might cause inconsistency in the scene-stage relation. |
Constructor Detail
Scene | ||
---|---|---|
public Scene( Stage parentStage )Creates a new scene belonging to the given Stage. Parameters:
See Also:
|
Method Detail
add | ||
---|---|---|
public void add( Entity entity ) Adds an entity to the scene. Parameters:
|
advance | ||
---|---|---|
public void advance( float elapsedTime ) Advances the animation for this scene. Subclasses should always call this superclass method,
as it handles physics and animation. Parameters:
|
getBackColor |
---|
public final RGB getBackColor() Gets the background color for this scene. The returned object is not a copy, and
modifications will take effect in the scene. Returns:
The background color |
getDialog |
---|
public final Dialog getDialog() Gets the current dialog that is currently showing on the scene. Dialogs halt the scene until
they are dismissed. Returns:
The current dialog See Also:
|
getPhysicsSimulator |
---|
public final PhysicsSimulator getPhysicsSimulator() Gets the default physics simulator for this Scene. The physics simulator is
originally null, but it is allocated on the first access, including the invocation of
this method. Returns:
The physics simulator See Also:
|
getStage |
---|
public final Stage getStage() Gets the stage that this scene is displayed on. Returns:
The parent stage |
getTouchMap |
---|
public final TouchMap getTouchMap() |
halt |
---|
public final void halt() Halts the scene. All animation and physics will stop until the scene is unhalted. Note that
although dialogs are also scenes, they cannot be halted. See Also:
|
handleInput | ||
---|---|---|
public void handleInput( GameInput inputManager ) Handles input for this scene. Parameters:
|
handleTouch |
---|
public boolean handleTouch( TouchEvent event ) Called whenever a touch event arrives. Specified By:
Returns:
true if handled, false otherwise |
isHalted |
---|
public final boolean isHalted() Indicates whether the scene is currently halted. Returns:
true if the scene is halted, and false otherwise |
isLoaded |
---|
public final boolean isLoaded() Indicates whether the resources for this scene are loaded. Returns:
true if loaded, and false otherwise |
onBackButton |
---|
public boolean onBackButton() Handles the back button event. Subclasses can override this method to handle the back button.
Calling the superclass method is not necessary. Returns:
true if handled, false if passed |
onDialogDismissed | ||
---|---|---|
protected void onDialogDismissed( Dialog dialog ) Called by the framework whenever a dialog is dismissed from the scene. Dialogs always invoke
this method on their parent scene when they are dismissed. Parameters:
See Also:
|
onHalted |
---|
protected void onHalted() Called by the framework after this scene goes to a halted state. You can override this method
for example to pause your game timers. |
onLoaded |
---|
public void onLoaded() Called by the framework when all resources for the scene are safely in place. It is a good
entry point for subclasses to create their objects and entities. Remember to call the
superclass method. |
onLocalLoad |
---|
public void onLocalLoad() Called by the framework to load scene-local resources. If a scene has local resources, it
should implement this method to load them. Within this method you can call the addLocal method from TextureManager to load your resources. Local resources are
automatically unloaded when the scene changes. |
onUnhalted | ||
---|---|---|
protected void onUnhalted( float delay ) Called by the framework after this scene goes out of a halted state. You can use this method
to resume your game timers. Parameters:
|
remove | ||
---|---|---|
public final void remove( Entity entity ) Removes an entity from the scene. Parameters:
|
render |
---|
public final void render( RenderingContext context ) Renders the scene on the given OpenGL context. |
setBackColor | ||
---|---|---|
public final void setBackColor( RGB color ) Sets the background color for this scene. Parameters:
|
setBackColor | ||||||
---|---|---|---|---|---|---|
public final void setBackColor( float r, float g, float b ) Sets the background color for this scene. Parameters:
|
unhalt |
---|
public final void unhalt() Un-halts a previously halted scene. All animation and physics will resume. |