Module flower.widget.Joystick
It is a virtual Joystick.
Extends:
Info:
- Release: V3.0.0
- Author: Makoto
Functions
Joystick:_initInternal () | Initializes the internal variables. |
Joystick:_initEventListeners () | Initializes the event listener. |
Joystick:_createChildren () | Initialize child objects that make up the Joystick. |
Joystick:updateDisplay () | Update the display. |
Joystick:updateKnob (x, y) | To update the position of the knob. |
Joystick:setCenterKnob () | Set the position of the center of the knob. |
Joystick:getCenterLoc () | Returns the position of the center of the whole. |
Joystick:getKnobNewLoc (x, y) | Returns the position that matches the mode of the stick. |
Joystick:getKnobNewLocForAnalog (x, y) | Returns the position to match the analog mode. |
Joystick:getKnobNewLocForDigital (x, y) | Returns the position to match the digital mode. |
Joystick:getKnobNewLocForDiagonal (x, y) | Returns the position to match the diagonal mode. |
Joystick:getKnobInputRate (x, y) | Returns the percentage of input. |
Joystick:getStickDirection () | Returns the direction of the stick. |
Joystick:getStickDirections () | Returns the direction of the stick. |
Joystick:getStickMode () | Returns the stick mode |
Joystick:setStickMode (mode) | Set the mode of the stick. |
Joystick:setKeyInputDispatchEnabled (value) | Set the keyInputDispatchEnabled |
Joystick:isTouchDown () | Returns the touched. |
Joystick:setOnStickChanged (func) | Set the event listener that is called when the stick changed. |
Joystick:onTouchDown (e) | This event handler is called when touched. |
Joystick:onTouchUp (e) | This event handler is called when the button is released. |
Joystick:onTouchMove (e) | This event handler is called when you move on the button. |
Joystick:onTouchCancel (e) | This event handler is called when you move on the button. |
Fields
STICK_CENTER | Direction of the stick |
STICK_LEFT | Direction of the stick |
STICK_TOP | Direction of the stick |
STICK_RIGHT | Direction of the stick |
STICK_BOTTOM | Direction of the stick |
MODE_ANALOG | Mode: analog |
MODE_DIGITAL | Mode: digital |
MODE_DIAGONAL | Mode: diagonal |
RANGE_OF_CENTER_RATE | The ratio of the center |
STYLE_BASE_TEXTURE | Style: baseTexture |
STYLE_KNOB_TEXTURE | Style: knobTexture |
Functions
- Joystick:_initInternal ()
- Initializes the internal variables.
- Joystick:_initEventListeners ()
- Initializes the event listener. You must not be called directly.
- Joystick:_createChildren ()
- Initialize child objects that make up the Joystick. You must not be called directly.
- Joystick:updateDisplay ()
- Update the display.
- Joystick:updateKnob (x, y)
-
To update the position of the knob.
Parameters:
- x The x-position of the knob
- y The y-position of the knob
- Joystick:setCenterKnob ()
- Set the position of the center of the knob.
- Joystick:getCenterLoc ()
-
Returns the position of the center of the whole.
Does not depend on the Pivot.
Returns:
- Center x-position
- Center y-position
- Joystick:getKnobNewLoc (x, y)
-
Returns the position that matches the mode of the stick.
Parameters:
- x X-position of the model
- y Y-position of the model
Returns:
- adjusted x-position
- adjusted y-position
- Joystick:getKnobNewLocForAnalog (x, y)
-
Returns the position to match the analog mode.
Parameters:
- x X-position of the model
- y Y-position of the model
Returns:
- adjusted x-position
- adjusted y-position
- Joystick:getKnobNewLocForDigital (x, y)
-
Returns the position to match the digital mode.
Parameters:
- x X-position of the model
- y Y-position of the model
Returns:
- adjusted x-position
- adjusted y-position
- Joystick:getKnobNewLocForDiagonal (x, y)
-
Returns the position to match the diagonal mode.
Parameters:
- x X-position of the model
- y Y-position of the model
Returns:
- adjusted x-position
- adjusted y-position
- Joystick:getKnobInputRate (x, y)
-
Returns the percentage of input.
Parameters:
- x X-position
- y Y-position
Returns:
- X-ratio(-1 <= x <= 1)
- Y-ratio(-1 <= y <= 1)
- Joystick:getStickDirection ()
-
Returns the direction of the stick.
Returns:
-
direction
- Joystick:getStickDirections ()
-
Returns the direction of the stick.
Returns:
- horizontal direction
- vertical direction
- Joystick:getStickMode ()
-
Returns the stick mode
Returns:
-
stick mode
- Joystick:setStickMode (mode)
-
Set the mode of the stick.
Parameters:
- mode mode("analog" or "digital")
- Joystick:setKeyInputDispatchEnabled (value)
-
Set the keyInputDispatchEnabled
Parameters:
- value true or false
- Joystick:isTouchDown ()
-
Returns the touched.
Returns:
-
stick mode
- Joystick:setOnStickChanged (func)
-
Set the event listener that is called when the stick changed.
Parameters:
- func stickChanged event handler
- Joystick:onTouchDown (e)
-
This event handler is called when touched.
Parameters:
- e Touch Event
- Joystick:onTouchUp (e)
-
This event handler is called when the button is released.
Parameters:
- e Touch Event
- Joystick:onTouchMove (e)
-
This event handler is called when you move on the button.
Parameters:
- e Touch Event
- Joystick:onTouchCancel (e)
-
This event handler is called when you move on the button.
Parameters:
- e Touch Event
Fields
- STICK_CENTER
- Direction of the stick
- STICK_LEFT
- Direction of the stick
- STICK_TOP
- Direction of the stick
- STICK_RIGHT
- Direction of the stick
- STICK_BOTTOM
- Direction of the stick
- MODE_ANALOG
- Mode: analog
- MODE_DIGITAL
- Mode: digital
- MODE_DIAGONAL
- Mode: diagonal
- RANGE_OF_CENTER_RATE
- The ratio of the center
- STYLE_BASE_TEXTURE
- Style: baseTexture
- STYLE_KNOB_TEXTURE
- Style: knobTexture