Read our guide on Joysticks before consulting this reference.
Adds a new static joystick to the screen at the given coordinates. A static joystick works only if you touch or click inside its outer radius. Other touches or clicks outside its outer radius will be ignored. Static doesn't mean immovable: you can move a static joystick by using the set center for joystick
block.
Joystick.addJoystick([INT], [NUMBER], [NUMBER], 0, 0, 0, 0, 0, false);
Adds a new relative joystick to the screen. For a relative joystick its center position is relative to the coordinates of mouse or touch first press. A relative joystick works only inside its own touch region.
Joystick.addJoystick([INT], [NUMBER], [NUMBER], 1, [NUMBER], [NUMBER], [NUMBER], [NUMBER], false);
Removes a joystick from the screen.
Joystick.removeJoystick([INT]);
The direction of the joystick will be set to this default direction when the joystick is idle.
Useful when you want an actor to face towards a particular direction when the player doesn't press the joystick. The default value of default direction is 0.
Joystick.setDefaultDirection([INT], [NUMBER]);
Sets the inner or the outer radius to a given value for a joystick.
The default value of the outer radius is half the width of the outer joystick. The default value of the inner radius is half the width of the inner joystick.
Joystick.setJoystickRadius([INT], true, [NUMBER]); //outer joystick
Joystick.setJoystickRadius([INT], false, [NUMBER]); //inner joystick
Sets the x position, y position, the width and the height of the touch region of a joystick. You can use this block to update the position and/or the size of a touch region of an existing relative joystick.
Joystick.setTouchRegionForRJ([INT], [NUMBER], [NUMBER], [NUMBER], [NUMBER]);
Sets the center position of a joystick.
Joystick.setJoystickCenter([INT], [NUMBER], [NUMBER]);
Sets the image of the outer or inner part of a joystick. You need to have corresponding images inside your games "extras" folder, one for each scale:
imagename.png
imagename@1.5x.png
imagename@2x.png
imagename@3x.png
imagename@4x.png
Joystick.setJoystickImage([INT], true, [TEXT]); //outer joystick
Joystick.setJoystickImage([INT], false, [TEXT]); //inner joystick
Sets the joystick image transparency for a joystick.
Joystick.setJoystickAlpha([INT], true, [NUMBER], true); //outer joystick when released
Joystick.setJoystickAlpha([INT], true, [NUMBER], false); //outer joystick when pressed
Joystick.setJoystickAlpha([INT], false, [NUMBER], true); //inner joystick when released
Joystick.setJoystickAlpha([INT], false, [NUMBER], false); //inner joystick when pressed
Makes a relative joystick to be always hidden when it is idle. Since the position of a relative joystick is not so important, you can use this block to always hide a relative joystick id when there is no press to save some screen space.
Joystick.alwaysHideRJ([INT]);
Returns 'true' if the joystick is being pressed, 'false' otherwise.
Joystick.isJoystickPressed([INT])
Returns the distance or the direction of a joystick.
Distance is always a float number between 0 and 1. Direction is always a float number between 0 (inclusive) and 360 (exclusive), where 0 means that the joystick is facing towards right, and 90 means that the joystick is facing down.
Joystick.getJoystickDisDir([INT], false) //direction
Joystick.getJoystickDisDir([INT], true) //distance
Returns the x or the y coordinate of the center of a joystick.
Joystick.getJoystickCenter([INT], true) //x
Joystick.getJoystickCenter([INT], false) //y
Returns the outer or inner radius value for a joystick.
Joystick.getJoystickRadius([INT], true) //outer joystick
Joystick.getJoystickRadius([INT], false) //inner joystick
Returns the position or size of the touch region for a relative joystick.
Joystick.getTouchRegionPropertyForRJ([INT], 1) //x
Joystick.getTouchRegionPropertyForRJ([INT], 2) //y
Joystick.getTouchRegionPropertyForRJ([INT], 3) //width
Joystick.getTouchRegionPropertyForRJ([INT], 4) //height