|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.jme.app.AbstractGame
AbstractGame defines a common method for implementing game functionality.
Client applications should not subclass AbstractGame directly.
| Field Summary | |
protected static int |
ALWAYS_SHOW_PROPS_DIALOG
Always displays a PropertiesDialog on startup. |
protected DisplaySystem |
display
Renderer used to display the game |
protected boolean |
finished
Flag for running the system. |
protected static int |
FIRSTRUN_OR_NOCONFIGFILE_SHOW_PROPS_DIALOG
Displays a PropertiesDialog only if the properties file is not
found or could not be loaded. |
protected static int |
NEVER_SHOW_PROPS_DIALOG
Never displays a PropertiesDialog on startup, using defaults
if no configuration file is found. |
protected PropertiesIO |
properties
Game display properties. |
| Constructor Summary | |
AbstractGame()
|
|
| Method Summary | |
protected void |
assertDisplayCreated()
assertDisplayCreated determines if the display system
was successfully created before use. |
protected abstract void |
cleanup()
cleanup cleans up any created objects before exiting the
application. |
void |
finish()
finish breaks out of the main game loop. |
protected void |
getAttributes()
getAttributes attempts to first obtain the properties
information from the "properties.cfg" file, then a dialog depending
on the dialog behaviour. |
java.lang.String |
getVersion()
getVersion returns the version of the API. |
protected abstract void |
initGame()
initGame creates and initializes all game data required
for startup. |
protected abstract void |
initSystem()
initSystem creates all the necessary system components
for the client application. |
protected abstract void |
quit()
quit exits the program. |
protected abstract void |
reinit()
reinit rebuilds the subsystems. |
protected abstract void |
render(float interpolation)
render displays the game information to the OpenGL context. |
void |
setDialogBehaviour(int behaviour)
setDialogBehaviour defines if and when the display properties
dialog should be shown. |
void |
setDialogBehaviour(int behaviour,
java.lang.String image)
setDialogBehaviour defines if and when the display properties
dialog should be shown as well as its accompanying image. |
void |
setDialogBehaviour(int behaviour,
java.net.URL image)
setDialogBehaviour sets how the properties dialog should
appear. |
abstract void |
start()
start begins the game. |
protected abstract void |
update(float interpolation)
update updates the game state. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected boolean finished
protected static final int NEVER_SHOW_PROPS_DIALOG
PropertiesDialog on startup, using defaults
if no configuration file is found.
protected static final int FIRSTRUN_OR_NOCONFIGFILE_SHOW_PROPS_DIALOG
PropertiesDialog only if the properties file is not
found or could not be loaded.
protected static final int ALWAYS_SHOW_PROPS_DIALOG
PropertiesDialog on startup.
protected PropertiesIO properties
protected DisplaySystem display
| Constructor Detail |
public AbstractGame()
| Method Detail |
public java.lang.String getVersion()
getVersion returns the version of the API.
protected void assertDisplayCreated()
throws JmeException
assertDisplayCreated determines if the display system
was successfully created before use.
JmeException - if the display system was not successfully createdpublic void setDialogBehaviour(int behaviour)
setDialogBehaviour defines if and when the display properties
dialog should be shown. Setting the behaviour after start has
been called has no effect.
behaviour - properties dialog behaviour ID
public void setDialogBehaviour(int behaviour,
java.lang.String image)
setDialogBehaviour defines if and when the display properties
dialog should be shown as well as its accompanying image. Setting the
behaviour after start has been called has no effect.
behaviour - properties dialog behaviour IDimage - a String specifying the filename of an image to be displayed
with the PropertiesDialog. Passing null
will result in no image being used.
public void setDialogBehaviour(int behaviour,
java.net.URL image)
setDialogBehaviour sets how the properties dialog should
appear. ALWAYS_SHOW_PROPS, NEVER_SHOW_PROPS and FIRSTRUN_OR_NOCONFIGFILE
are the three valid choices. The url of an image file is also used so
you can customize the dialog.
behaviour - ALWAYS_SHOW_PROPS, NEVER_SHOW_PROPS and
FIRSTRUN_OR_NOCONFIGFILE are the valid choices.image - the image to display in the box.protected void getAttributes()
getAttributes attempts to first obtain the properties
information from the "properties.cfg" file, then a dialog depending
on the dialog behaviour.
public abstract void start()
start begins the game. The game is initialized by calling
first initSystem then initGame. Assuming no
errors were encountered during initialization, the main game loop is
entered. How the loop operates is implementation-dependent. After the
game loop is broken out of via a call to finish,
cleanup is called. Subclasses should declare this method
final.
public void finish()
finish breaks out of the main game loop. It is preferable to
call finish instead of quit.
protected abstract void quit()
quit exits the program. By default, it simply uses the
System.exit() method.
protected abstract void update(float interpolation)
update updates the game state. Physics, AI, networking, score
checking and like should be completed in this method. How often and when
this method is called depends on the main loop implementation.
interpolation - definition varies on implementation, -1.0f if unusedprotected abstract void render(float interpolation)
render displays the game information to the OpenGL context.
Nothing altering the game state should be run during a render. How often
and when this method is called depends on the main loop implementation.
interpolation - definition varies on implementation, -1.0f if unusedprotected abstract void initSystem()
initSystem creates all the necessary system components
for the client application. It is is called once after start
is called. The display must be initialized within this method.
protected abstract void initGame()
initGame creates and initializes all game data required
for startup. It is suggested that caching of frequently used resources
is done within this method. It is called once after initSystem
has completed.
protected abstract void reinit()
reinit rebuilds the subsystems. It may be called at any time
by the client application.
protected abstract void cleanup()
cleanup cleans up any created objects before exiting the
application. It is called once after finish is called.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||