Artenus 2D Framework
Artenus Reference
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 TypeField and Description
protected stage
Holds the parent stage for this scene.

Constructor Summary

Modifier and TypeConstructor and Description
public Scene(Stage parentStage)
Creates a new scene belonging to the given Stage.

Method Summary

Modifier and TypeMethod and Description
public voidadd(Entity entity)
Adds an entity to the scene.
public voidadvance(float elapsedTime)
Advances the animation for this scene.
public final RGBgetBackColor()
Gets the background color for this scene.
public final DialoggetDialog()
Gets the current dialog that is currently showing on the scene.
public final PhysicsSimulatorgetPhysicsSimulator()
Gets the default physics simulator for this Scene.
public final StagegetStage()
Gets the stage that this scene is displayed on.
public final TouchMapgetTouchMap()
public final voidhalt()
Halts the scene.
public voidhandleInput(GameInput inputManager)
Handles input for this scene.
public booleanhandleTouch(TouchEvent event)
Called whenever a touch event arrives.
public final booleanisHalted()
Indicates whether the scene is currently halted.
public final booleanisLoaded()
Indicates whether the resources for this scene are loaded.
public booleanonBackButton()
Handles the back button event.
protected voidonDialogDismissed(Dialog dialog)
Called by the framework whenever a dialog is dismissed from the scene.
protected voidonHalted()
Called by the framework after this scene goes to a halted state.
public voidonLoaded()
Called by the framework when all resources for the scene are safely in place.
public voidonLocalLoad()
Called by the framework to load scene-local resources.
protected voidonUnhalted(float delay)
Called by the framework after this scene goes out of a halted state.
public final voidremove(Entity entity)
Removes an entity from the scene.
public final voidrender(RenderingContext context)
Renders the scene on the given OpenGL context.
public final voidsetBackColor(RGB color)
Sets the background color for this scene.
public final voidsetBackColor(float r, float g, float b)
Sets the background color for this scene.
public final voidunhalt()
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:
parentStageThe parent stage
See Also:

Method Detail

add
public void add(
    Entity entity
)
Adds an entity to the scene.
Parameters:
entityThe entity to be added
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:
elapsedTimeThe time elapsed since last frame
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:
inputManagerThe input manager that triggered the event
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:
dialogThe dismissed dialog
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:
delayThe time passed, in seconds, in the halted state
remove
public final void remove(
    Entity entity
)
Removes an entity from the scene.
Parameters:
entityThe entity to be removed
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:
colorThe background color
setBackColor
public final void setBackColor(
    float r,
    float g,
    float b
)
Sets the background color for this scene.
Parameters:
rThe red component of the background color
gThe green component of the background color
bThe blue component of the background color
unhalt
public final void unhalt()
Un-halts a previously halted scene. All animation and physics will resume.