This class provides information about the current state of a given
Wii Remote. This interface supports up to 4 remotes, their button
states, twist angles, connected statuses, cursor positions, and
whether or not the remotes are facing the screen. Note that this
class should not be used directly, but should be obtained through
either Wii.getRemote(<id>) or
Wii.getPrimaryRemote().
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 WiiRemote
constants:
| Constant |
| BUTTON_UP |
| BUTTON_DOWN |
| BUTTON_LEFT |
| BUTTON_RIGHT |
| BUTTON_1 |
| BUTTON_2 |
| BUTTON_A |
| BUTTON_B |
| BUTTON_PLUS |
| BUTTON_MINUS |
if(Wii.getPrimaryRemote().isDown(WiiRemote.BUTTON_B)) { ...do logic... }static public BUTTON_UP:Numberstatic public BUTTON_DOWN:Numberstatic public BUTTON_RIGHT:Numberstatic public BUTTON_LEFT:Numberstatic public BUTTON_1:Numberstatic public BUTTON_2:Numberstatic public BUTTON_A:Numberstatic public BUTTON_B:Numberstatic public BUTTON_PLUS:Numberstatic public BUTTON_MINUS:Numberpublic function getIdentity():NumberEach Wii console is capable of connecting to up to four Wii Remotes. Each of these remotes has a numerical identity. These identites range from 0 for the first remote to 3 for the fourth remote. This function returns the numerical identity of this remote.
The identity of this Wii Remote. Possible values are 0, 1, 2, and 3.
public function isPrimary():Boolean
If this remote is the one currently able to interact with the webpage,
this function will return true. See Wii.getPrimaryRemote()
for more information.
true if this remote is the primary, false otherwise
public function isConnected():BooleanThis function can be used to determine if a Wii Remote is powered on or not. Remotes that are connected to the Wii return true, while remotes that are powered off or non-existant return a value of false.
true if the remote is powered on, false otherwise
public function isRotated():BooleanReturns true if the interface is configured to use the Wii Remote in a sideways configuration. False is returned if the remote is configured for vertical use. The default value is false.
public function setRotated(rotate:Boolean):VoidSwitches the Wii Remote between vertical configuration and sideways configuration. Default is false for vertical configuration. This setting is ignored when not running on a Nintendo Wii.
rotate | True for sideways configuration, false for vertical configuration. |
public function getTwistAngle():Number
This function provides the angle of rotation of the remote when rotated
with the wrist. Because this feature uses the IR sensor on the front of
the remote, this information is only updated when the remote is facing
the screen. Since the Wii cursor utilizes the same information, the
rotation of the cursor will match the value returned by this function.
If the remote is pointed away from the screen, the last known angle
will be reported. If this presents a problem for your game, use the
isFacingScreen() function to determine whether this value is currently
being updated or not.
The value returned is in the range of 0 to 359 degrees. To translate
this value to a range of -180 to +179, simply subtract 180 from the
value returned. e.g.:
var angle = Wii.getPrimaryRemote().getTwistAngle() - 180;
A value between 0 and 359 representing the angle of rotation.
public function getDistance():NumberThis function provides the Wii Remote's distance from the screen. This feature makes use of the IR Sensor on the front of the remote, and only operates when the remote is facing the screen. This function can return values between 0 and 800. However, the minimum value when in use appears to be 52. A value of 0 is returned when distance information is not available.
A value between 0 and 800 representing the Wii Remote's distance from the television.
public function getCursorX():Number
Returns the X coordinate of the cursor on the screen. Coordinates are
automatically mapped to the coordinate-space of the flash movie. Thus
this function should return the same result as _mousex would. The
primary difference is that this interface is capable of returning
values outside the range of the movie. So it is possible to get
a negative value or a value larger than the width of the movie.
Note that the standard mice features work in Flash on the Wii, but only for the
primary remote. If you wish to support more than one remote, you will
need to use this function instead.
An integer representing the current screen X position of the cursor.
public function getCursorY():Number
Returns the Y coordinate of the cursor on the screen. Coordinates are
automatically mapped to the coordinate-space of the flash movie. Thus
this function should return the same result as _mousey would. The
primary difference is that this interface is capable of returning
values outside the range of the movie. So it is possible to get
a negative value or a value larger than the height of the movie.
Note that the standard mice features work in Flash on the Wii, but only for the
primary remote. If you wish to support more than one remote, you will
need to use this function instead.
An integer representing the current screen Y position of the cursor.
public function isFacingScreen():Boolean
This function allows you to determine if the remote is facing toward the
screen or away. This information is important as many of the Wii Remote's
features only work while the controller is facing the screen.
Other interesting uses for this function include auto-pausing of the
game ala the "spotlight" feature in Super Paper Mario. It can
also be used to automatically rotate the controller's interface if
the controller is facing away from the screen.
True if the remote is facing the screen, false otherwise.
public function isDown(buttonCode):BooleanUse this function to check if a Wii Remote button is pressed.
buttonCode | One of the WiiBrowser.BUTTON_<name> constants.
|
True if the button is pressed, false if not.
public function getAttachment()Returns an interface to the current Wii Remote attachment. As of the current version, only the Nunchuk is supported.
An instance of the Nunchuk object.
public function addEventListener(type:String, listener:Function):VoidThis function can be used to register an event listener for any of the following events:
Wii.getPrimaryRemote().addEventListener("buttondown", onButtonDown);
function onButtonDown(event)
{
if(event.buttonCode == WiiRemote.BUTTON_B)
{
trace("The B button was pressed on remote #"+event.identity);
}
}
type | A string representing the type of event to listen for. |
listener | The function to call when the event is fired. |