Class TouchScreenButton
- Namespace
- Godot
- Assembly
- GodotSharp.dll
TouchScreenButton allows you to create on-screen buttons for touch devices. It's intended for gameplay use, such as a unit you have to touch to move. Unlike Button, TouchScreenButton supports multitouch out of the box. Several TouchScreenButtons can be pressed at the same time with touch input.
This node inherits from Node2D. Unlike with Control nodes, you cannot set anchors on it. If you want to create menus or user interfaces, you may want to use Button nodes instead. To make button nodes react to touch events, you can enable the Emulate Mouse option in the Project Settings.
You can configure TouchScreenButton to be visible only on touch devices, helping you develop your game both for desktop and mobile devices.
public class TouchScreenButton : Node2D, IDisposable
- Inheritance
-
TouchScreenButton
- Implements
- Inherited Members
Constructors
TouchScreenButton()
public TouchScreenButton()
Properties
Action
The button's action. Actions can be handled with InputEventAction.
public string Action { get; set; }
Property Value
Bitmask
The button's bitmask.
public Bitmap Bitmask { get; set; }
Property Value
PassbyPress
If true
, the Pressed and Released signals are emitted whenever a pressed finger goes in and out of the button, even if the pressure started outside the active area of the button.
Note: This is a "pass-by" (not "bypass") press mode.
public bool PassbyPress { get; set; }
Property Value
Shape
The button's shape.
public Shape2D Shape { get; set; }
Property Value
ShapeCentered
If true
, the button's shape is centered in the provided texture. If no texture is used, this property has no effect.
public bool ShapeCentered { get; set; }
Property Value
ShapeVisible
If true
, the button's shape is visible in the editor.
public bool ShapeVisible { get; set; }
Property Value
TextureNormal
The button's texture for the normal state.
public Texture2D TextureNormal { get; set; }
Property Value
TexturePressed
The button's texture for the pressed state.
public Texture2D TexturePressed { get; set; }
Property Value
VisibilityMode
The button's visibility mode. See TouchScreenButton.VisibilityModeEnum for possible values.
public TouchScreenButton.VisibilityModeEnum VisibilityMode { get; set; }
Property Value
Methods
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
IsPressed()
Returns true
if this button is currently pressed.
public bool IsPressed()
Returns
Events
Pressed
Emitted when the button is pressed (down).
public event Action Pressed
Event Type
Released
Emitted when the button is released (up).
public event Action Released