overview wiki api reference download
 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:
gameplay::Control gameplay::Ref gameplay::AnimationTarget gameplay::ScriptTarget

List of all members.

Public Member Functions

const char * getTypeName () const
void addListener (Control::Listener *listener, int eventFlags)
const Vector2getValue () const
void setInnerRegionSize (const Vector2 &size, bool isWidthPercentage=false, bool isHeightPercentage=false)
const Vector2getInnerRegionSize (bool *isWidthPercentage=NULL, bool *isHeightPercentage=NULL) const
void setOuterRegionSize (const Vector2 &size, bool isWidthPercentage=false, bool isHeightPercentage=false)
const Vector2getOuterRegionSize (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 JoystickControlcreate (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 Controlcreate (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

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:
listenerThe listener to add.
eventFlagsThe 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:
idThe joystick ID.
styleThe 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:
styleThe style to apply to this joystick.
propertiesA 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:
isWidthPercentageSet to true if the width value is a percentage value of the relative size of this control
isHeightPercentageSet 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:
isWidthPercentageSet to true if the width value is a percentage value of the relative size of this control
isHeightPercentageSet 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)

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.

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.

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

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:
sizeThe size of the inner region of the joystick. (x, y) == (width, height)
isWidthPercentageIf the width value should be computed as a percentage of the relative size of this control
isHeightPercentageIf 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:
sizeThe size of the outer region of the joystick. (x, y) == (width, height)
isWidthPercentageIf the width value should be computed as a percentage of the relative size of this control
isHeightPercentageIf 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:
radiusThe radius to be set.
isPercentageIf 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:
relativeWhether 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:
evtThe touch event that occurred.
xThe x position of the touch in pixels. Left edge is zero.
yThe y position of the touch in pixels. Top edge is zero.
contactIndexThe 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