|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectvooga.engine.state.GameState
public abstract class GameState
GameState is, at its most basic conception, a container class for collections of sprites. Beyond that, it should be used to control state-specific behavior that defines those sprites. For example, the mainGameState should include all of the sprites necessary to play the game in both the render and update groups. The mainGameState, when set to active, will then iterate through those sprites and render and update them appropriately. Additional behavior can be called in the gameState' render or update methods to provide high-level functionality (i.e. functionality to be preserved across the entire gameState, not a specific level). GameStates show their power most of all when changing states. As an example, take the change from a mainGameState into a pausedGameState. The pausedGameState could be constructed using the mainGameState's sprites as render-only sprites, effectively "freezing" the action by no longer updating those sprites. A menu could then be added as rendered+updated sprites, displayed over the "frozen" action. Returning to the main game flow is as simple as toggling back to the mainGameState.
Field Summary | |
---|---|
protected java.util.Collection<PlayField> |
myRenderField
|
protected java.util.Collection<PlayField> |
myUpdateField
|
Constructor Summary | |
---|---|
GameState()
Constructs a new GameState play |
|
GameState(GameState gamestate)
Constructs a new GameState using another GameState as the base. |
|
GameState(PlayField playfield)
Creates a new GameState from a Playfield by placing all SpriteGroups in render and update groups. |
Method Summary | |
---|---|
void |
activate()
Sets the GameState to active. |
void |
addGroup(SpriteGroup group)
|
void |
addPlayField(PlayField playfield)
Adds a playfield to an rendered and updated in an existing GameState |
void |
addRenderPlayField(PlayField playfield)
Adds a playfield to an rendered in an existing GameState |
void |
addRenderState(GameState gamestate)
Adds the contents of an existing GameState to the current state's renderGroups. |
void |
addState(GameState gamestate)
Adds the contents of an existing GameState to the current state's render and updateGroups. |
void |
addUpdatePlayField(PlayField playfield)
Adds a playfield to an updated in an existing GameState |
void |
addUpdateState(GameState gamestate)
Adds the contents of an existing GameState to the current state's updateGroups. |
void |
deactivate()
Sets the GameState to inactive. |
boolean |
equals(java.lang.Object obj)
Equals function for GameStates |
SpriteGroup |
getGroup(java.lang.String name)
Get a SpriteGroup out of the GameState if it exists. |
java.util.Collection<PlayField> |
getRenderField()
Returns the GameState's renderGroups. |
java.util.Collection<PlayField> |
getUpdateField()
Returns the GameState's updateGroups. |
abstract void |
initialize()
The initialize method sets up specific variables and parameters necessary to the specific functioning of the GameState. |
boolean |
isActive()
Returns the boolean value of the GameState's active variable. |
void |
removeEverything()
Clears the GameState of all contents. |
void |
render(java.awt.Graphics2D g)
Renders all sprites stored in the GameState's renderGroups. |
void |
update(long t)
Updates all sprites stored in the GameState' updateGroups. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Collection<PlayField> myRenderField
protected java.util.Collection<PlayField> myUpdateField
Constructor Detail |
---|
public GameState()
public GameState(GameState gamestate)
gamestate
- public GameState(PlayField playfield)
playfield
- Method Detail |
---|
public void activate()
public void deactivate()
public abstract void initialize()
public boolean isActive()
public void render(java.awt.Graphics2D g)
g
- public void update(long t)
t
- public java.util.Collection<PlayField> getRenderField()
public java.util.Collection<PlayField> getUpdateField()
public void addRenderState(GameState gamestate)
gamestate
- public void addUpdateState(GameState gamestate)
gamestate
- public void addState(GameState gamestate)
gamestate
- public void addPlayField(PlayField playfield)
playfield
- to be rendered and updatedpublic void addRenderPlayField(PlayField playfield)
playfield
- to be renderedpublic void addUpdatePlayField(PlayField playfield)
playfield
- to be updatedpublic void removeEverything()
public SpriteGroup getGroup(java.lang.String name)
name
- the name of the SpriteGroup
public void addGroup(SpriteGroup group)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Object
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |