Packageua.table.gamepad
Classpublic class DeviceGamepad
InheritanceDeviceGamepad Inheritance flash.events.EventDispatcher
Implements ua.table.game.IDeviceListener

Works with remote device, initializes it, listens messages and allows other useful things. Use this to start work with remote device. Handles simple moving logic.

You can start by just instantiating this class with your main character as parameter:

   var gamepad:DeviceGamepad = new DeviceGamepad(hero, stage);
   

It will place Pin reader popup in center of the stage, and start triggering events as soon as connection will be esteblished. You can store gamepad to use it's minimal implementation of move logic. see verticalDirection() and horizontalDirection() for more information on movement.

You can also listen to current state of connectivity by adding Event.CONNECT and Event.CLOSE listeners on this object. These will signal you if game should start, or pause.



Public Properties
 PropertyDefined By
  device : Device
[read-only] Access to underlaying device.
DeviceGamepad
  horizontalDirection : Number
[read-only] Indicates current horizontal moving direction.
DeviceGamepad
  isFireOn : Boolean
[read-only] Indicates current fire state.
DeviceGamepad
  isSwitchOn : Boolean
[read-only] Indicates current switch weapon state.
DeviceGamepad
  verticalDirection : Number
[read-only] Indicates current vertical moving direction.
DeviceGamepad
Public Methods
 MethodDefined By
  
DeviceGamepad(listener:IGamepadListener, root:DisplayObjectContainer, x:Number, y:Number)
Upon creating this class, you will be instantly promted ro enter device PIN.
DeviceGamepad
  
close():void
Closes connection with device.
DeviceGamepad
Property Detail
deviceproperty
device:Device  [read-only]

Access to underlaying device.


Implementation
    public function get device():Device
horizontalDirectionproperty 
horizontalDirection:Number  [read-only]

Indicates current horizontal moving direction. -1 denotes left, 1 denotes right.


Implementation
    public function get horizontalDirection():Number
isFireOnproperty 
isFireOn:Boolean  [read-only]

Indicates current fire state.


Implementation
    public function get isFireOn():Boolean
isSwitchOnproperty 
isSwitchOn:Boolean  [read-only]

Indicates current switch weapon state.


Implementation
    public function get isSwitchOn():Boolean
verticalDirectionproperty 
verticalDirection:Number  [read-only]

Indicates current vertical moving direction. -1 denotes up, 1 denotes down.


Implementation
    public function get verticalDirection():Number
Constructor Detail
DeviceGamepad()Constructor
public function DeviceGamepad(listener:IGamepadListener, root:DisplayObjectContainer, x:Number, y:Number)

Upon creating this class, you will be instantly promted ro enter device PIN. Use parameters to constructor to control how it should be displayed.

Parameters
listener:IGamepadListener — - should implement game logic. DeviceGamepad calls appropriate functions upon this object,
 
root:DisplayObjectContainer — - where to display PIN reader,
 
x:Number (default = NaN) — - if set together with y - indicates x position of spawned PIN reader.
 
y:Number (default = NaN) — - if set together with x - indicates y position of spawned PIN reader.
Method Detail
close()method
public function close():void

Closes connection with device.