Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

psastras::engine::Engine Class Reference

Collaboration diagram for psastras::engine::Engine:
Collaboration graph
[legend]

List of all members.

Classes

class  EngineInstance

Public Member Functions

long startTime ()
void pause ()
void resume ()
void start ()
DrawHandler drawHandler ()
PhysicsHandler physicsHandler ()
long elapsedTime ()
void addUpdateHandler (UpdateHandler handler)
MessageHandler messageHandler ()
BitmapManager imageManager ()
TouchInputHandler touchHandler ()
KeyboardInputHandler keyboardHandler ()
boolean isRunning ()

Static Public Member Functions

static void init (Context context, EngineSettings settings)
static Engine instance ()

Protected Member Functions

void check ()
void applySettings (EngineSettings settings)

Protected Attributes

EngineSettings settings_
ArrayList< UpdateHandlerupdateHandlers_
MessageHandler msgHandler_
DrawHandler drawHandler_
PhysicsHandler physicsHandler_
TouchInputHandler touchHandler_
KeyboardInputHandler keyboardHandler_
Context context_
long startTime_
boolean isRunning_

Detailed Description

The base 2D game engine. This is a singleton class which is automatically instantiated by the engine activity. It's instance can be accessed by calling Engine.instance() to retrieve the singleton instance.

Keep in mind that the settings you initialize the engine with persist throughout the life of the engine, and cannot be changed (so if you want to use sound, you must initiate the engine with the appropriate settings - see EngineActivity for more information).

Author:
psastras

Member Function Documentation

void psastras::engine::Engine::addUpdateHandler ( UpdateHandler  handler  )  [inline]

Adds an UpdateHandler to the Engine's list of UpdateHandlers. This UpdateHandler will be paused / resumed when the Engine is paused and/or resumed.

Parameters:
handler The UpdateHandler to add.
void psastras::engine::Engine::applySettings ( EngineSettings  settings  )  [inline, protected]

Applies the current engine settings to the engine. This should only be called once. The DrawHandler, ImageManager, and PhysicsManger, as well as other Engine instance variables are instantiated here.

Parameters:
settings The EngineSettings to initialize to.
void psastras::engine::Engine::check (  )  [inline, protected]

Checks the engine settings and provided handlers as well as systems specs to ensure that the engine settings are compatible with the current setup. If the settings are not compatible, errors will be output, but the engine will try to continue setup anyway - although this may result in weird behavior.

DrawHandler psastras::engine::Engine::drawHandler (  )  [inline]

Returns the instance of the DrawHandler associated with the engine.

Returns:
The DrawHandler instance.
long psastras::engine::Engine::elapsedTime (  )  [inline]

Returns the elapsed time of the engine since the last start() or paus() in milliseconds.

Returns:
Elapsed time in milliseconds.
BitmapManager psastras::engine::Engine::imageManager (  )  [inline]

Returns the ImageManager class associated with the Engine. Note that since the ImageManager is itself a singleton class, the ImageManager can be accessed by simply calling ImageManager.instance() from any other class.

Returns:
The ImageManager instance.
static void psastras::engine::Engine::init ( Context  context,
EngineSettings  settings 
) [inline, static]

Initializes the engine by instantiating / calling the Engine's constructor. This should only be called once, since it will overwrite the previous Engine's instance (since this is a singleton class).

Parameters:
context The main application context.
settings Engine settings to instantiate the Engine with.
static Engine psastras::engine::Engine::instance (  )  [inline, static]

Returns the static instance of the Engine. You should use this method whenever you need to access any of the Engine's members (methods).

Returns:
Returns the singleton instance of the Engine.
boolean psastras::engine::Engine::isRunning (  )  [inline]

Returns whether or not the Engine is currently running. This is false if pause() was last called, or if start() has not yet been called, and true otherwise, or if resume() / start() has been called last.

Returns:
Whether the Engine is currently running.
KeyboardInputHandler psastras::engine::Engine::keyboardHandler (  )  [inline]

Returns the KeyboardInputHandler instance associated with the Engine. The keyboard handler is responsible for handling all ui keyboard input events fired by a Surface.

Returns:
The KeyboardInputHandler instance.
MessageHandler psastras::engine::Engine::messageHandler (  )  [inline]

Returns the MessageHandler class associated with the Engine.

Returns:
The MessageHandler;
void psastras::engine::Engine::pause (  )  [inline]

Pauses the game engine as well as all of its associated update handlers. Each update handler should be responsible for pausing itself (ex. notifications) The games running state is set to false (see isRunning_)

PhysicsHandler psastras::engine::Engine::physicsHandler (  )  [inline]

Returns the instance of the PhysicsHandler associated with the engine.

Returns:
The PhysicsHandler instance.
void psastras::engine::Engine::resume (  )  [inline]

Resumes the game engine as well as all of its associated update handlers. Each update handler should be responsible for resuming itself (Ex. notifcations) The game's running state is set to true (see isRunning_), and the previous startTime_ is reset to the current system time in milliseconds.

void psastras::engine::Engine::start (  )  [inline]

Starts running the engine. This method should only be called once to restart a paused engine, use resume, which will skip the engine check. If you are extending / implementing EngineActivity, you should not need to call this method.

TouchInputHandler psastras::engine::Engine::touchHandler (  )  [inline]

Returns the TouchHandler instance associated with the Engine. The touch handler is responsible for handling all ui touch input events fired by a Surface.

Returns:
The TouchInputHandler instance.

The documentation for this class was generated from the following file:
 All Classes Functions Variables