-
Notifications
You must be signed in to change notification settings - Fork 19
EventListener
Fabio Ticconi edited this page Jul 30, 2016
·
6 revisions
Checklist:
- Public
- Annotated with
@Subscribe - Exactly one parameter derived from
Eventclass.
@Subscribe
public void myCustomListener( MyEvent event )
{
..
}You can also cancel events, and prioritize event handling.
You can catch more than one event type by using an event superclass as parameter.
If PlayerDeathEvent and MonsterDeathEvent extend DeathEvent, they will both trigger public void myCustomListener( DeathEvent event )
Provided the EventSystem is part of your World, all listeners on system and manager classes are automatically registered upon world initialization.
Systems or managers added to a world after initialization must be manually registered. see 'Listeners on other objects' below.
Listeners on an object outside Artemis are supported. They are resolved with the active ListenerFinderStrategy.
eventSystem.registerEvents(myObject);