Control

public abstract class Control

Represents a virtual joystick control.

Custom control must inherit from this class.

Inheritors

Constructors

Link copied to clipboard
public Control Control(Float invalidRadius, JoystickView.DirectionType directionType)

Types

Link copied to clipboard
public final class Builder

A builder class to build a control for the default ones.

Link copied to clipboard
public enum DefaultType extends Enum<Control.DefaultType>

Properties

Link copied to clipboard
private final Double anglePosition

Calculates the angle (clockwise) formed from the current position and center.

Link copied to clipboard
private final ImmutablePosition center

Gets the immutable position of control center.

Link copied to clipboard

Gets the direction to which the control is pointing. It is based on the anglePosition value, but if distanceFromCenter is less than invalidRadius, the direction is considered as Direction.NONE.

Link copied to clipboard

The control directions type.

Link copied to clipboard
private final Float distanceFromCenter

Calculates the distance between current position and center.

Link copied to clipboard

The control drawer.

Link copied to clipboard

Invalid radius to be taken into account when obtaining control direction.

Link copied to clipboard

Gets the immutable position of control position.

Link copied to clipboard

Gets the parametric position of current position in the view circle.

Link copied to clipboard
private final Double viewRadius

Gets the radius of the view where the control is used.

Functions

Link copied to clipboard
protected final Float deltaX()

Calculates the difference in the x-coordinate between the current position and the center.

Link copied to clipboard
protected final Float deltaY()

Calculates the difference in the y-coordinate between the current position and the center.

Link copied to clipboard
public final Double getAnglePosition()
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The control directions type.

Link copied to clipboard
Link copied to clipboard
public abstract ControlDrawer getDrawer()

The control drawer.

Link copied to clipboard
public final Float getInvalidRadius()

Invalid radius to be taken into account when obtaining control direction.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
public final Double getViewRadius()
Link copied to clipboard
public final Boolean isInCenter()

Checks if current position is an the same center coordinates.

Link copied to clipboard
public Unit onDraw(Canvas canvas)

Method to draw the control using the drawer.

Link copied to clipboard
public final Unit onSizeChanged(Size size)

Called (or call it) when the size of the view changes.

Link copied to clipboard
public final Unit setDirectionType(JoystickView.DirectionType directionType)

The control directions type.

Link copied to clipboard
public abstract Unit setDrawer(ControlDrawer drawer)

The control drawer.

Link copied to clipboard
public final Unit setInvalidRadius(Float invalidRadius)
Link copied to clipboard
public final Unit setPosition(ImmutablePosition position)
public final Unit setPosition(Float x, Float y)

Sets the current position of the control.

Link copied to clipboard
public final Unit toCenter()

Sets the current position to center.

Link copied to clipboard
protected final Unit validatePositionValues()

Validates the control position values.