Documentation
¶
Overview ¶
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 ProjectSettings "input_devices/pointing/emulate_mouse_from_touch" 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.
Index ¶
- type Advanced
- type Any
- type Extension
- type ID
- type Instance
- func (self Instance) Action() string
- func (self Instance) AsCanvasItem() CanvasItem.Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsNode2D() Node2D.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsTouchScreenButton() Instance
- func (self Instance) Bitmask() BitMap.Instance
- func (self Instance) ID() ID
- func (self Instance) IsPressed() bool
- func (self Instance) OnPressed(cb func(), flags ...Signal.Flags)
- func (self Instance) OnReleased(cb func(), flags ...Signal.Flags)
- func (self Instance) PassbyPress() bool
- func (self Instance) SetAction(value string)
- func (self Instance) SetBitmask(value BitMap.Instance)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetPassbyPress(value bool)
- func (self Instance) SetShape(value Shape2D.Instance)
- func (self Instance) SetShapeCentered(value bool)
- func (self Instance) SetShapeVisible(value bool)
- func (self Instance) SetTextureNormal(value Texture2D.Instance)
- func (self Instance) SetTexturePressed(value Texture2D.Instance)
- func (self Instance) SetVisibilityMode(value VisibilityMode)
- func (self Instance) Shape() Shape2D.Instance
- func (self Instance) ShapeCentered() bool
- func (self Instance) ShapeVisible() bool
- func (self Instance) TextureNormal() Texture2D.Instance
- func (self Instance) TexturePressed() Texture2D.Instance
- func (self Instance) Virtual(name string) reflect.Value
- func (self Instance) VisibilityMode() VisibilityMode
- type VisibilityMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsCanvasItem ¶
func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance
func (*Extension[T]) AsTouchScreenButton ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
type Instance [1]gdclass.TouchScreenButton
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) Action ¶
The button's action. Actions can be handled with InputEventAction.
func (Instance) AsCanvasItem ¶
func (self Instance) AsCanvasItem() CanvasItem.Instance
func (Instance) AsTouchScreenButton ¶
func (Instance) OnReleased ¶
Emitted when the button is released (up).
func (Instance) PassbyPress ¶
If true, the OnPressed and OnReleased 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.
func (Instance) SetBitmask ¶
SetBitmask sets the property returned by [GetBitmask].
func (Instance) SetPassbyPress ¶
SetPassbyPress sets the property returned by [IsPassbyPressEnabled].
func (Instance) SetShapeCentered ¶
SetShapeCentered sets the property returned by [IsShapeCentered].
func (Instance) SetShapeVisible ¶
SetShapeVisible sets the property returned by [IsShapeVisible].
func (Instance) SetTextureNormal ¶
SetTextureNormal sets the property returned by [GetTextureNormal].
func (Instance) SetTexturePressed ¶
SetTexturePressed sets the property returned by [GetTexturePressed].
func (Instance) SetVisibilityMode ¶
func (self Instance) SetVisibilityMode(value VisibilityMode)
SetVisibilityMode sets the property returned by [GetVisibilityMode].
func (Instance) ShapeCentered ¶
If true, the button's shape is centered in the provided texture. If no texture is used, this property has no effect.
func (Instance) ShapeVisible ¶
If true, the button's shape is visible in the editor.
func (Instance) TextureNormal ¶
The button's texture for the normal state.
func (Instance) TexturePressed ¶
The button's texture for the pressed state.
func (Instance) VisibilityMode ¶
func (self Instance) VisibilityMode() VisibilityMode
The button's visibility mode.
type VisibilityMode ¶
type VisibilityMode int //gd:TouchScreenButton.VisibilityMode
const ( // Always visible. VisibilityAlways VisibilityMode = 0 // Visible on touch screens only. VisibilityTouchscreenOnly VisibilityMode = 1 )