PDG engine v0.9.5
 All Classes Namespaces Functions Variables Groups Pages
Public Member Functions | Related Functions | List of all members
EventManager Class Reference

Distributes events to event handlers. More...

Inheritance diagram for EventManager:
Inheritance graph
[legend]
Collaboration diagram for EventManager:
Collaboration graph
[legend]

Public Member Functions

object getDeviceOrientation (boolean absolute=false)
 NOT IMPLEMENTED get the roll, pitch and yaw of the device
 
boolean isButtonDown (int buttonNumber=0)
 check if button is down
 
boolean isKeyDown (string unicodeChar)
 check if a key is down
 
boolean isKeyDown (uint utf16CharCode)
 check if a key is down
 
boolean isRawKeyDown (int keyCode)
 check if a key is down
 
- Public Member Functions inherited from EventEmitter
 addHandler (IEventHandler inHandler, int inEventType=all_events)
 add a new handler for some event type, or for all events if no type specified.
 
 blockEvent (int inEventType)
 temporarily ignore all events of a particular type.
 
 clear ()
 remove all handlers
 
 removeHandler (IEventHandler inHandler, int inEventType=all_events)
 remove a handler for some event type, or for all events (see note) if no type specified.
 
 unblockEvent (int inEventType)
 stop ignoring events of a particular type
 

Related Functions

(Note that these are not member functions.)

 evt
 the singleton instance of the EventManager
 
 getEventManager
 get the singleton instance of the EventManager used by the pdg framework
 

Detailed Description

Distributes events to event handlers.

Precondition
API Stability: 3 - Stable. The API has proven satisfactory, but cleanup in the underlying code may cause minor changes. Backwards-compatibility is guaranteed.

The EventManager is the core ofthe Pixel Dust Games Framework. All inputs to your game arrive as events via the Event Manager. This includes network messages and system level notifications in addition to user inputs such as keystrokes and mouse movements.

The EventManager expects the game developer to implement IEventHandler subclasses and register them to handle various events they are interested in.

See Also
IEventHandler

Member Function Documentation

getDeviceOrientation ( boolean  absolute = false)

NOT IMPLEMENTED get the roll, pitch and yaw of the device

On mobile devices which allow the screen to be oriented different ways, this reports the current relative roll, pitch and yaw of the device. If absolute is if absolute is true, then yaw is compass direction from north around vertical axis, pitch is rotation around E -> W axis, and roll is rotation around N -> S axis

Parameters
absoluteflag to indicate if roll, pitch and yaw are around compass directions (true) or relative (false)
Returns
object with roll, pitch and yaw values
Todo:
NOT IMPLEMENTED
isButtonDown ( int  buttonNumber = 0)

check if button is down

Check the state of a particular mouse button or finger touch. For touch devices the number represents the order the fingers went down rather than specific physical buttons as on a mouse.

Parameters
buttonNumberthe particular mouse button; defaults to zero, the left mouse button or first touch
Returns
true if the button down or the finger is touching, or false if not
isKeyDown ( string  unicodeChar)

check if a key is down

Check the state of a particular key as passed in a string. The string should be a single character that matches the value returned in KeyPressEvent.unicode for the desired key. If the string passed has multiple characters, only the first character will be used. This form of the call is typically used for printable characters.

var eKeyDown = pdg.evt.isKeyDown('E');
Parameters
unicodeCharthe character that is generated by the key to be checked
Returns
true if the key is pressed, or false if not
See Also
KeyPressEvent
Key Code Constants
isKeyDown ( uint  utf16CharCode)

check if a key is down

Check the state of a particular key as passed as a UTF-16 character code value. This code matches the value returned in KeyPressEvent.unicode for the desired key. This is the form that would be used for non-printable codes such as key_UpArrow, key_Enter, etc...

var upKeyPressed = pdg.evt.isKeyDown(pdg.key_UpArrow);
Parameters
utf16CharCodethe unicode value that is generated by the key to be checked
Returns
true if the key is pressed, or false if not
See Also
KeyPressEvent
Key Code Constants
isRawKeyDown ( int  keyCode)

check if a key is down

Check the state of a particular key as passed as raw OS/hardware specific value. This code matches the value returned in KeyEvent.keyCode for the desired key. Since the keyCode values usually won't be known ahead of time, this is mainly useful when your app gives the user the ability to custom map keys to particular functions.

var mappedKeyValue = event.keyCode; // save the user's key mapping
...
// check to see if the key the user mapped is pressed
var myMappedKeyPressed = pdg.evt.isKeyDown(mappedKeyValue);
Parameters
keyCodethe raw OS key code that is generated by the key to be checked
Returns
true if the key is pressed, or false if not
See Also
KeyEvent

Friends And Related Function Documentation

getEventManager
related

get the singleton instance of the EventManager used by the pdg framework

Returns
EventManager singleton object

User Comments