Skip to content

as3dpad is a virtual gamepad designed for Adobe AIR mobile. You can develop a iOS/Android game and receive user data from the touch screen. X and Y axis data will be represented to “UP”, “DOWN”, “LEFT”, “RIGHT” and a radians.

License

Notifications You must be signed in to change notification settings

duckleg/as3dpad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

as3dpad

as3dpad is a virtual gamepad designed for Adobe AIR mobile. You can develop a iOS/Android game and receive user data from the touch screen. X and Y axis data will be represented to “UP”, “DOWN”, “LEFT”, “RIGHT” and a radians.

Explain01 Explain02

Features

  • X and Y-axis
  • A, B, C and D Buttons
  • custom UI
  • key mapping for development on desktop (WASD + m,./)
  • available with stage3d (e.g.: Starling, Away3D, Alternativa3D...)

What does work

First of all, you'll create an instance of the DPad and add to the stage.

var dPad:DPad = new DPad();
this.addChild(dPad);

Add a detection listener for AxisPad. You'll get values on X and Y-axis.

dPad.leftPad.addEventListener(DPadEvent.TOUCH_PRESS, touchPressHandler);
dPad.leftPad.addEventListener(DPadEvent.TOUCH_RELEASE, touchReleaseHandler);

private function touchPressHandler(event:DPadEvent):void{
  var axisPad:AxisPad = event.target as AxisPad;
  trace("radians: " + axisPad.radians);
  trace("distance: " + axisPad.distance + "/" + axisPad.maxDistance);
  trace("press left:  " + (axisPad.value & AxisPad.LEFT));
  trace("press right: " + (axisPad.value & AxisPad.RIGHT));
  trace("press up:    " + (axisPad.value & AxisPad.UP));
  trace("press down:  " + (axisPad.value & AxisPad.DOWN));
}
private function touchReleaseHandler(event:DPadEvent):void{
  ...
}

Add a detection listener for GroupPad. You'll get values on A and B buttons.

dPad.rightPad.addEventListener(DPadEvent.TOUCH_PRESS_A, touchPressAHandler);
dPad.rightPad.addEventListener(DPadEvent.TOUCH_PRESS_B, touchPressBHandler);
dPad.rightPad.addEventListener(DPadEvent.TOUCH_RELEASE_A, touchReleaseAHandler);
dPad.rightPad.addEventListener(DPadEvent.TOUCH_RELEASE_B, touchReleaseBHandler);

private function touchPressAHandler(event:DPadEvent):void{
  var groupPad:GroupPad = event.target as GroupPad;
  trace("press A: " + (groupPad.value & GroupPad.A_BUTTON));
  trace("press B: " + (groupPad.value & GroupPad.B_BUTTON));
}
private function touchPressBHandler(event:DPadEvent):void{
	...
}
private function touchReleaseAHandler(event:DPadEvent):void{
	...
}
private function touchReleaseBHandler(event:DPadEvent):void{
	...
}

Examples

  • example01_basic demo
  • example02_custom_UI demo
  • example03_double_AxisPad demo
  • example04_touch9Grid demo
  • example05_starling demo

Launch Examples Launch Examples Launch Examples Launch Examples Launch Examples

(Click the image to see some demos. Be patient, no preloader!)

Download

SWC Library - as3dpad.swc

License

Copyright (C) 2012 Marco Wong, http://flash-adobe.blogspot.hk/

Licence Agreement (The MIT License)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

as3dpad is a virtual gamepad designed for Adobe AIR mobile. You can develop a iOS/Android game and receive user data from the touch screen. X and Y axis data will be represented to “UP”, “DOWN”, “LEFT”, “RIGHT” and a radians.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published