API Docs for:
Show:

KeyboardInputSystem Class

This system is reponsible for translating key presses into actions for entities that have the Input component. This system checks which keys are pressed and for each entity, if that key press translates into an action, it sends an event with that action as the name and the entity as the argument.

Constructor

KeyboardInputSystem

(
  • entitySystemManager
)

Parameters:

  • entitySystemManager Manager

    The entity system manager whose entities this system will be working on.

Methods

destroy

()

disable

()

Disables input handling for all entities.

enable

()

Enables input handling for all entities.

subscribe

(
  • event
  • callback
  • [subscriber]
)

Parameters:

  • event String

    Name of the event being subscribed to.

  • callback Function

    Function that will be called back when the specified event is triggered.

  • [subscriber] Object optional

    An optional parameter that specifies an object that's subscribing. When a function is subscribed with an object, that function will be called back with "this" set to the object.

trigger

(
  • event
  • [eventObject]
)

Triggers the event, calling all functions that subscribed to it.

Parameters:

  • event String

    The event to be triggered.

  • [eventObject] Object optional

    All functions that were subscribed to the specified event will be called with this as the argument.

unsubscribe

(
  • event
  • [callback]
  • [subscriber]
)

This is a multi-purpose method. See the example for all the ways it can be overloaded.

Parameters:

  • event Object
  • [callback] Object optional
  • [subscriber] Object optional

Example:

   //Unsubscribing all callbacks for a given event.
  eventHandler.unsubscribe('eventName');

  //Unsubscribing all callbacks subscribed by the object.
  eventHandler.unsubscribe(object);

  //Unsubscribing all callbacks an object made for the given event.
  eventHandler.unsubscribe('eventName', object);

  //Unsubscribing a callback that was subscribed with an object.
  eventHandler.unsubscribe('eventName', callback, object);

  //Unsubscribing a callback subscribed by itself.
  eventHandler.unsubscribe('eventName', callback);
  //The last method can't be used to unsubscribe callbacks which were subscribed with an object.

update

()