Table of Contents

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

string

Bitmask

The button's bitmask.

public Bitmap Bitmask { get; set; }

Property Value

Bitmap

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

bool

Shape

The button's shape.

public Shape2D Shape { get; set; }

Property Value

Shape2D

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

bool

ShapeVisible

If true, the button's shape is visible in the editor.

public bool ShapeVisible { get; set; }

Property Value

bool

TextureNormal

The button's texture for the normal state.

public Texture2D TextureNormal { get; set; }

Property Value

Texture2D

TexturePressed

The button's texture for the pressed state.

public Texture2D TexturePressed { get; set; }

Property Value

Texture2D

VisibilityMode

The button's visibility mode. See TouchScreenButton.VisibilityModeEnum for possible values.

public TouchScreenButton.VisibilityModeEnum VisibilityMode { get; set; }

Property Value

TouchScreenButton.VisibilityModeEnum

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_name

Name of the method to check for.

Returns

bool

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_name

Name of the signal to check for.

Returns

bool

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_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

IsPressed()

Returns true if this button is currently pressed.

public bool IsPressed()

Returns

bool

Events

Pressed

Emitted when the button is pressed (down).

public event Action Pressed

Event Type

Action

Released

Emitted when the button is released (up).

public event Action Released

Event Type

Action