|  | overview |  | wiki |  | api reference |  | download

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions
gameplay::JoystickControl Class Reference

`#include <JoystickControl.h>`

Inheritance diagram for gameplay::JoystickControl:

List of all members.

## Public Member Functions

const char * | getTypeName () const
void | addListener (Control::Listener *listener, int eventFlags)
const Vector2 & | getValue () const
void | setInnerRegionSize (const Vector2 &size, bool isWidthPercentage=false, bool isHeightPercentage=false)
const Vector2 & | getInnerRegionSize (bool *isWidthPercentage=NULL, bool *isHeightPercentage=NULL) const
void | setOuterRegionSize (const Vector2 &size, bool isWidthPercentage=false, bool isHeightPercentage=false)
const Vector2 & | getOuterRegionSize (bool *isWidthPercentage=NULL, bool *isHeightPercentage=NULL) const
void | setRelative (bool relative)
bool | isRelative () const
unsigned int | getIndex () const
void | setRadius (float radius, bool isPercentage=false)
float | getRadius () const
bool | isRadiusPercentage () const

## Static Public Member Functions

static JoystickControl * | create (const char *id, Theme::Style *style=NULL)

## Protected Member Functions

| JoystickControl ()
virtual | ~JoystickControl ()
void | initialize (const char *typeName, Theme::Style *style, Properties *properties)
bool | touchEvent (Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
void | updateAbsoluteBounds (const Vector2 &offset)
unsigned int | drawImages (Form *form, const Rectangle &clip)

## Static Protected Member Functions

static Control * | create (Theme::Style *style, Properties *properties=NULL)

## Detailed Description

Defines a control representing a joystick (axis).

This is used in virtual Gamepad instances.

See also:
  http://gameplay3d.github.io/GamePlay/docs/file-formats.html#wiki-UI_Forms

## Constructor & Destructor Documentation

gameplay::JoystickControl::JoystickControl | ( |  | ) | `[protected]`

Constructor.

virtual gameplay::JoystickControl::~JoystickControl | ( |  | ) | `[protected, virtual]`

Destructor.

## Member Function Documentation

void gameplay::JoystickControl::addListener | ( | Control::Listener * | listener,
|  | int | eventFlags
| ) |  | `[virtual]`

Add a listener to be notified of specific events affecting this control. Event types can be OR'ed together. E.g. To listen to touch-press and touch-release events, pass `Control::Listener::TOUCH | Control::Listener::RELEASE` as the second parameter.

Parameters:

  listener | The listener to add.
  eventFlags | The events to listen for.

Reimplemented from gameplay::Control.

static JoystickControl* gameplay::JoystickControl::create | ( | const char * | id,
|  | Theme::Style * | style = `NULL`
| ) |  | `[static]`

Creates a new Joystick control.

Parameters:

  id | The joystick ID.
  style | The joystick style.

Returns:
  The new joystick.

static Control* gameplay::JoystickControl::create | ( | Theme::Style * | style,
|  | Properties * | properties = `NULL`
| ) |  | `[static, protected]`

Create a joystick control with a given style and properties.

Parameters:

  style | The style to apply to this joystick.
  properties | A properties object containing a definition of the joystick.

Returns:
  The new joystick.

unsigned int gameplay::JoystickControl::drawImages | ( | Form * | form,
|  | const Rectangle & | clip
| ) |  | `[protected, virtual]`

See also:
  Control::drawImages

Reimplemented from gameplay::Control.

unsigned int gameplay::JoystickControl::getIndex | ( |  | ) | const

Gets the index of this joystick across all joysticks on a form.

Returns:
  The index of this joystick on a form.

const Vector2& gameplay::JoystickControl::getInnerRegionSize | ( | bool * | isWidthPercentage = `NULL`,
|  | bool * | isHeightPercentage = `NULL`
| ) |  | const

Gets the image size of the inner region of the joystick. Returns (0,0) if there is no inner image region defined.

Parameters:

  isWidthPercentage | Set to true if the width value is a percentage value of the relative size of this control
  isHeightPercentage | Set to true if the height value is a percentage value of the relative size of this control

Returns:
  The image size of the inner region of the joystick. (x, y) == (width, height)

const Vector2& gameplay::JoystickControl::getOuterRegionSize | ( | bool * | isWidthPercentage = `NULL`,
|  | bool * | isHeightPercentage = `NULL`
| ) |  | const

Gets the image size of the outer region of the joystick. Returns (0,0) if there is no outer image region defined.

Parameters:

  isWidthPercentage | Set to true if the width value is a percentage value of the relative size of this control
  isHeightPercentage | Set to true if the height value is a percentage value of the relative size of this control

Returns:
  The image size of the outer region of the joystick. (x, y) == (width, height)

float gameplay::JoystickControl::getRadius | ( |  | ) | const

Gets the radius of joystick motion

Returns:
  The radius of joystick motion

const char* gameplay::JoystickControl::getTypeName | ( |  | ) | const`[virtual]`

Extends ScriptTarget::getTypeName() to return the type name of this class.

Child controls should override this function to return the correct type name.

Returns:
  The type name of this class: "JoystickControl"

See also:
  ScriptTarget::getTypeName()

Reimplemented from gameplay::Control.

const Vector2& gameplay::JoystickControl::getValue | ( |  | ) | const

Gets the value (2-dimensional direction) of the joystick.

Returns:
  The value of the joystick.

void gameplay::JoystickControl::initialize | ( | const char * | typeName,
|  | Theme::Style * | style,
|  | Properties * | properties
| ) |  | `[protected, virtual]`

See also:
  Control::initialize

Reimplemented from gameplay::Control.

bool gameplay::JoystickControl::isRadiusPercentage | ( |  | ) | const

Determines if the radius of joystick motion is a percentage value of the relative size of this control

Returns:
  True if the radius of joystick motion is a percentage value of the relative size of this control

bool gameplay::JoystickControl::isRelative | ( |  | ) | const

Gets whether absolute positioning is enabled or not.

Note: The default behavior is absolute positioning, and not relative.

Returns:
  `true` if relative positioning is enabled; `false` otherwise.

void gameplay::JoystickControl::setInnerRegionSize | ( | const Vector2 & | size,
|  | bool | isWidthPercentage = `false`,
|  | bool | isHeightPercentage = `false`
| ) |  |

Sets the image size of the inner region of the joystick. Does not do anything if there is no inner image region defined.

Parameters:

  size | The size of the inner region of the joystick. (x, y) == (width, height)
  isWidthPercentage | If the width value should be computed as a percentage of the relative size of this control
  isHeightPercentage | If the height value should be computed as a percentage of the relative size of this control

void gameplay::JoystickControl::setOuterRegionSize | ( | const Vector2 & | size,
|  | bool | isWidthPercentage = `false`,
|  | bool | isHeightPercentage = `false`
| ) |  |

Sets the image size of the outer region of the joystick. Does not do anything if there is no outer image region defined.

Parameters:

  size | The size of the outer region of the joystick. (x, y) == (width, height)
  isWidthPercentage | If the width value should be computed as a percentage of the relative size of this control
  isHeightPercentage | If the height value should be computed as a percentage of the relative size of this control

void gameplay::JoystickControl::setRadius | ( | float | radius,
|  | bool | isPercentage = `false`
| ) |  |

Sets the radius of joystick motion

Parameters:

  radius | The radius to be set.
  isPercentage | If the radius value is a percentage value of the relative size of this control

void gameplay::JoystickControl::setRelative | ( | bool | relative | ) |

Sets whether relative positioning is enabled or not.

Note: The default behavior is absolute positioning, and not relative.

Parameters:

  relative | Whether relative positioning should be enabled or not.

bool gameplay::JoystickControl::touchEvent | ( | Touch::TouchEvent | evt,
|  | int | x,
|  | int | y,
|  | unsigned int | contactIndex
| ) |  | `[protected, virtual]`

Touch callback on touch events. Controls return true if they consume the touch event.

Parameters:

  evt | The touch event that occurred.
  x | The x position of the touch in pixels. Left edge is zero.
  y | The y position of the touch in pixels. Top edge is zero.
  contactIndex | The order of occurrence for multiple touch contacts starting at zero.

Returns:
  Whether the touch event was consumed by the control.

See also:
  Touch::TouchEvent

Reimplemented from gameplay::Control.

void gameplay::JoystickControl::updateAbsoluteBounds | ( | const Vector2 & | offset | ) | `[protected, virtual]`

See also:
  Control::updateAbsoluteBounds

Reimplemented from gameplay::Control.

All Classes Functions Variables Typedefs Enumerations Enumerator