Class VirtualJoystick
Constructors
constructor
-
new VirtualJoystick(
leftJoystick?: boolean,
customizations?: Partial<IVirtualJoystickCustomizations>,
): VirtualJoystickCreates a new virtual joystick
Parameters
OptionalleftJoystick: booleandefines that the joystick is for left hand (false by default)
Optionalcustomizations: Partial<IVirtualJoystickCustomizations>Defines the options we want to customize the VirtualJoystick
Returns VirtualJoystick
Properties
delta Position
Gets the offset value for the position (ie. the change of the position value)
limit To Container
boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
pressed
Gets a boolean indicating if the virtual joystick was pressed
reverse Left Right
Gets or sets a boolean indicating that left and right values must be inverted
reverse Up Down
Gets or sets a boolean indicating that up and down values must be inverted
StaticCanvas
Canvas the virtual joystick will render onto, default z-index of this is 5
Accessors
always Visible
-
get alwaysVisible(): boolean
Returns boolean
-
set alwaysVisible(value: boolean): void
Defines whether or not the joystick container is always visible
Parameters
- value: boolean
Returns void
container Size
-
get containerSize(): number
Returns number
-
set containerSize(newSize: number): void
Size of the joystick's container
Parameters
- newSize: number
Returns void
puck Size
-
get puckSize(): number
Returns number
-
set puckSize(newSize: number): void
Size of the joystick's puck
Parameters
- newSize: number
Returns void
Methods
clear Position
-
Clears the set position of the joystick
Returns void
release Canvas
-
Release internal HTML canvas
Returns void
set Action On Touch
-
Defines a callback to call when the joystick is touched
Parameters
- action: () => any
defines the callback
Returns void
- action: () => any
set Axis For Left Right
-
Defines which axis you'd like to control for left & right
Parameters
- axis: JoystickAxis
defines the axis to use
Returns void
- axis: JoystickAxis
set Axis For Up Down
-
Defines which axis you'd like to control for up & down
Parameters
- axis: JoystickAxis
defines the axis to use
Returns void
- axis: JoystickAxis
set Container Image
-
Loads
urlPathto be used for the container's imageParameters
- urlPath: string
defines the urlPath of an image to use
Returns void
- urlPath: string
set Joystick Color
-
Change the color of the virtual joystick
Parameters
- newColor: string
a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
Returns void
- newColor: string
set Joystick Sensibility
-
Defines joystick sensibility (ie. the ratio between a physical move and virtual joystick position change)
Parameters
- newJoystickSensibility: number
defines the new sensibility
Returns void
- newJoystickSensibility: number
set Position
-
Sets the constant position of the Joystick container
Parameters
- x: number
X axis coordinate
- y: number
Y axis coordinate
Returns void
- x: number
set Puck Image
-
Loads
urlPathto be used for the puck's imageParameters
- urlPath: string
defines the urlPath of an image to use
Returns void
- urlPath: string
Class used to define virtual joystick (used in touch mode)