This class provides information about one of the Nunchuck attachment
controllers. This class cannot be instantiated directly and should
only be obtained through the WiiRemote.getAttachment()
function.
Button states can be to polled to determine whether a given button
is pressed or not. To determine this information, call the
isDown() function with one of the following Nunchuk
constants:
| Constant |
| BUTTON_C |
| BUTTON_Z |
if(Wii.getRemote(1).getAttachment().isDown(Nunchuk.BUTTON_Z)) { ...do logic... }public function isDown(buttonCode):BooleanUse this function to check if a Nunchuo button is pressed.
buttonCode | One of the Nunchuk.BUTTON_<name> constants.
|
True if the button is pressed, false if not.
public function getStickX():Number
This function returns the current X value of the Nunchuk's
thumbstick. The thumbstick may report a value between -128
and +128. The value is 0 when the stick is centered.
Please note that this function does not provide any useful
information at this time. It is included for completeness
and forward compatibility only.
An integer between -128 and +128.
public function getStickY():Number
This function returns the current Y value of the Nunchuk's
thumbstick. The thumbstick may report a value between -128
and +128. The value is 0 when the stick is centered.
Please note that this function does not provide any useful
information at this time. It is included for completeness
and forward compatibility only.
An integer between -128 and +128.
public function addEventListener(type:String, listener:Function):VoidThis function can be used to register an event listener for any of the following events:
Wii.getRemote(1).getAttachment().addEventListener("buttondown", onButtonDown);
function onButtonDown(event)
{
if(event.buttonCode == Nunchuk.BUTTON_Z)
{
trace("The Z button was pressed on the nunchuk "+
"attached to remote #"+event.identity);
}
}
type | A string representing the type of event to listen for. |
listener | The function to call when the event is fired. |