public class VirtualButton
- Object
- VirtualButton
An on-screen touch button. Add one with TouchControls#addButton(int, float, float, float); while a finger is on it the framework holds down the key code it
is mapped to, so GameInput#isKeyDown(int) and GameInput#wasKeyPressed(int)
report it exactly as a hardware key. Map it to a game action with
com.codename1.ui.Display#getKeyCode(int) (e.g.
Display.getInstance().getKeyCode(Display.GAME_FIRE)) or to any key code of your
own.
The position and radius are in the GameView’s pixel coordinates.
Methods
public VirtualButton setLabel(String label) | Optional short label drawn on the button (for example “A” or “Fire”). |
public VirtualButton setColor(int argb) | The ARGB color the button is tinted (default a translucent white). |
public boolean isPressed() | |
public int getKeyCode() | |
public float getCenterX() | |
public float getCenterY() | |
public float getRadius() | |
public String getLabel() | |
public int getColor() |
Inherited methods
Method details
setLabel
public VirtualButton setLabel(String label)Optional short label drawn on the button (for example “A” or “Fire”).
setColor
public VirtualButton setColor(int argb)The ARGB color the button is tinted (default a translucent white).
isPressed
public boolean isPressed()getKeyCode
public int getKeyCode()getCenterX
public float getCenterX()getCenterY
public float getCenterY()getRadius
public float getRadius()getLabel
public String getLabel()getColor
public int getColor()