com.jmex.game.state
Class CameraGameState

java.lang.Object
  extended by com.jmex.game.state.GameState
      extended by com.jmex.game.state.BasicGameState
          extended by com.jmex.game.state.CameraGameStateDefaultCamera
              extended by com.jmex.game.state.CameraGameState

public class CameraGameState
extends CameraGameStateDefaultCamera

A typical game state that initializes a rootNode, camera and a ZBufferState.

In update(float) we call updateGeometricState(0, true) on the rootNode, and in render(float) we draw it.

stateUpdate and stateRender can be filled with custom logic. Much like in SimpleGame.

The setActive method will trigger the onActivate/onDeactivate methods, giving derived classes an opportunity to perform special actions. E.g. start/stop playing menu music and such. Beware though; the onActivate method points the renderer to the camera contained by this state, so if you override it you must remember to call super.onActivate().

Author:
Per Thulin

Field Summary
protected  Camera cam
          The camera of this game state.
 
Fields inherited from class com.jmex.game.state.BasicGameState
rootNode
 
Fields inherited from class com.jmex.game.state.GameState
active, name, parent
 
Constructor Summary
CameraGameState(java.lang.String name)
          Inits rootNode, camera and ZBufferState.
 
Method Summary
 Camera getCamera()
          Gets the camera of this state.
protected  void initCamera()
          Initializes a standard camera.
protected  void onActivate()
          Points the renderers camera to the one contained by this state.
 void setCamera(Camera cam)
          Sets the camera of this state.
 
Methods inherited from class com.jmex.game.state.CameraGameStateDefaultCamera
getRootNode, initZBuffer, onDeactivate, render, setActive, stateRender, stateUpdate, update
 
Methods inherited from class com.jmex.game.state.BasicGameState
cleanup
 
Methods inherited from class com.jmex.game.state.GameState
getName, getParent, isActive, setName, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cam

protected Camera cam
The camera of this game state.

Constructor Detail

CameraGameState

public CameraGameState(java.lang.String name)
Inits rootNode, camera and ZBufferState. Also invokes initInput().

Parameters:
name - The name of this GameState.
Method Detail

onActivate

protected void onActivate()
Points the renderers camera to the one contained by this state. Derived classes can put special actions they want to perform when activated here.

Specified by:
onActivate in class CameraGameStateDefaultCamera

getCamera

public Camera getCamera()
Gets the camera of this state.

Returns:
The camera of this state.

setCamera

public void setCamera(Camera cam)
Sets the camera of this state.


initCamera

protected void initCamera()
Initializes a standard camera.