Class Direction

java.lang.Object
  extended by Direction

public class Direction
extends java.lang.Object

An immutable class that describes a returned axis direction from the joypad. This includes the direction and it's strength.

The user should never need to create these themselves, instead they will be created and returned for you by the GamePad class.

Author:
Joseph Lenton

Constructor Summary
Direction(int angle, float strength)
          Creates a new direction.
 
Method Summary
 int getAngle()
          Angles are in degrees from 0 to 359, with 0 pointing to the east.
 double getAngleRadians()
          Returns the same value as the getAngle method, however this is in radians instead of degrees.
 float getStrength()
          Strength represents how far the axis is pushed in the given direction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Direction

public Direction(int angle,
                 float strength)

Creates a new direction. These are typically created for you by the GamePad class.

Parameters:
The - angle for this direction in degrees.
How - strong the direction is moving in the given angle.
Method Detail

getAngle

public int getAngle()

Angles are in degrees from 0 to 359, with 0 pointing to the east.

Returns:
The angle that this is pointing in.

getAngleRadians

public double getAngleRadians()

Returns the same value as the getAngle method, however this is in radians instead of degrees.

This is useful for when you are using the static trigonomic methods in the Math class, like Math.cos() and Math.sin().

Returns:
The angle this is pointing in, in radians.

getStrength

public float getStrength()

Strength represents how far the axis is pushed in the given direction. 0 is that it is not being pushed at all, and 1 is that it is fully exerted as far as it can move. 0.5 would be moving the axis half way of the given direction.

Returns:
The strength of the direction from 0 to 1.