|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Class Summary | |
---|---|
Demo2 | This demo Demo2 shows how to use EventPool and IEventHandler to create
events in game. |
Human | A Human character in the demo example. |
HumanKilledbyZombieEvent | Class HumanKilledbyZombieEvent implements the interface IEventHandler to create
an event for the ZombieLand game. |
Zombie | A Zombie character in the demo example. |
The example which utilizes the event system will demonstrate how to use the event system which includes how to register or listen to an event as well as fire a event when the event is triggered. The event will be automatically fired and received in game loop when the event is triggered.
The Event system the example used primarily includes two classes whose names are EventPool and IEventHandler. IEventHandler is interface while EventPool is an class.
Every class which implements IEventHandler
interface can be added into EventPool
for checking the events later in game loop.
Please see the event classes in this package.
Taking ZombieLand game for example,Strong zombies, enemies of weak human, are trying to catch human in one line and end the game. The speed of the zombie is faster than human. Here is the fire event condition: when the zombie catches up with human which indicated by their x position, the human will be killed the killevent will be triggered. In this case, we can write a event class such as HumanKilledbyZombieEvent.Add it in the EventLoop class. And the eventLoop will check the event for you.
|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |