as3-controller-input icon indicating copy to clipboard operation
as3-controller-input copied to clipboard

xbox 360 analog coordinate system misaligned to flash coordinate system

Open mattlohkamp opened this issue 12 years ago • 1 comments

this might be more of a feature request or a 'FYI' than an issue.

flash's (as you know) graph looks like this:

  • North: -y
  • East: +x
  • South: +y
  • West: -x

the XboxController.leftStick.x & XboxController.leftStick.y, however, are aligned like so:

  • North: +y
  • East: +x
  • South: -y
  • West:-x

... and since XboxController.leftStick.angle is derived from that x/y orientation, you end up with radian values...

  • North: PI/2
  • East: 0
  • South: -PI/2
  • West: PI (or -PI)

... that are rotated and reflected from what flash expects:

  • North: 0
  • East: 90
  • South: 180 (or -180)
  • West: -90

which is a very very roundabout way of saying that if you try to rotate a sprite to match the analog stick angle, it won't line up properly:

sprite.rotation = controller.leftStick.angle * (180 / PI); // for radians '0', with stick in 'east' position, sprite doesn't rotate, stays pointed 'north'

mattlohkamp avatar Dec 30 '13 05:12 mattlohkamp

so since I had to write a little workaround to convert the analog stick's radians into flash's degrees, maybe I'll give you a pull request for a version that includes a property for a flash-friendly rotation value on sticks.

mattlohkamp avatar Dec 30 '13 05:12 mattlohkamp