|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IGame
Interface for representing games. A game is responsible for creating the window in which all drawing takes place, accepting and drawing IGameObject instances and allowing IGameObject instances to register listeners for timer, keypress, collision and screen exit events. Instead of creating the initial game objects in the constructor, implementations of this interface should create these objects in the onGameStart() method. This will ensure that the game can be re-intialised without creating a new game instance.
Method Summary | |
---|---|
void |
add(IGameObject object)
Adds object to the game. |
void |
addCollisionListener(IGameObject object,
ICollisionListener listener)
Registers a collision listener that will be notified whenever a collision occurs between object and any other IGameObject. |
void |
addKeyListener(IGameObject object,
Key key,
IKeyListener listener)
Registers a key listener that will be notified of every timer tick that occurs while the given key is pressed. |
void |
addScreenExitListener(IGameObject object,
IScreenExitListener listener)
Registers a screen exit listener that will be notified whenever object leaves the screen. |
void |
addTimerListener(IGameObject object,
ITimerListener listener)
Registers a timer listener that will be called after every cycle of the main game loop. |
void |
onGameStart()
Called just before the main game loop is started. |
void |
remove(IGameObject object)
Removes object from the game. |
void |
start()
Starts this game. |
Method Detail |
---|
void start()
void add(IGameObject object)
object
- The IGameObject to be added.void remove(IGameObject object)
object
- The IGameObject to be removed.void addTimerListener(IGameObject object, ITimerListener listener)
object
- The object registering this listener.listener
- The listener to register.void addCollisionListener(IGameObject object, ICollisionListener listener)
object
- The listener will be notified whenever this object collides
with another object in the game.listener
- The listener to register.void addScreenExitListener(IGameObject object, IScreenExitListener listener)
object
- The listener will be notified whenever this object leaves the
screen.listener
- The listener to register.void addKeyListener(IGameObject object, Key key, IKeyListener listener)
object
- The object registering this listener.key
- The listener will be notified while this key is pressed.listener
- The listener to register.void onGameStart()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |