Documentation
¶
Overview ¶
Package Sprite2D provides methods for working with Sprite2D object instances.
Index ¶
- type Advanced
- type Any
- type Extension
- type ID
- type Instance
- 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) AsSprite2D() Instance
- func (self Instance) Centered() bool
- func (self Instance) FlipH() bool
- func (self Instance) FlipV() bool
- func (self Instance) Frame() int
- func (self Instance) FrameCoords() Vector2i.XY
- func (self Instance) GetRect() Rect2.PositionSize
- func (self Instance) Hframes() int
- func (self Instance) ID() ID
- func (self Instance) IsPixelOpaque(pos Vector2.XY) bool
- func (self Instance) Offset() Vector2.XY
- func (self Instance) OnFrameChanged(cb func(), flags ...Signal.Flags)
- func (self Instance) OnTextureChanged(cb func(), flags ...Signal.Flags)
- func (self Instance) RegionEnabled() bool
- func (self Instance) RegionFilterClipEnabled() bool
- func (self Instance) RegionRect() Rect2.PositionSize
- func (self Instance) SetCentered(value bool)
- func (self Instance) SetFlipH(value bool)
- func (self Instance) SetFlipV(value bool)
- func (self Instance) SetFrame(value int)
- func (self Instance) SetFrameCoords(value Vector2i.XY)
- func (self Instance) SetHframes(value int)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetOffset(value Vector2.XY)
- func (self Instance) SetRegionEnabled(value bool)
- func (self Instance) SetRegionFilterClipEnabled(value bool)
- func (self Instance) SetRegionRect(value Rect2.PositionSize)
- func (self Instance) SetTexture(value Texture2D.Instance)
- func (self Instance) SetVframes(value int)
- func (self Instance) Texture() Texture2D.Instance
- func (self *Instance) UnsafePointer() unsafe.Pointer
- func (self Instance) Vframes() int
- func (self Instance) Virtual(name string) reflect.Value
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]) AsSprite2D ¶
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 ¶
A node that displays a 2D texture. The texture displayed can be a region from a larger atlas texture, or a frame from a sprite sheet animation.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsCanvasItem ¶
func (self Instance) AsCanvasItem() CanvasItem.Instance
func (Instance) AsSprite2D ¶
func (Instance) FrameCoords ¶
func (Instance) GetRect ¶
func (self Instance) GetRect() Rect2.PositionSize
Returns a [Rect2] representing the Sprite2D's boundary in local coordinates. [b]Example:[/b] Detect if the Sprite2D was clicked: [codeblocks] [gdscript] func _input(event):
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT: if get_rect().has_point(to_local(event.position)): print("A click!")
[/gdscript] [csharp] public override void _Input(InputEvent @event)
{ if (@event is InputEventMouseButton inputEventMouse) { if (inputEventMouse.Pressed && inputEventMouse.ButtonIndex == MouseButton.Left) { if (GetRect().HasPoint(ToLocal(inputEventMouse.Position))) { GD.Print("A click!"); } } } }
[/csharp] [/codeblocks]
func (Instance) IsPixelOpaque ¶
Returns [code]true[/code], if the pixel at the given position is opaque and [code]false[/code] in other case. The position is in local coordinates. [b]Note:[/b] It also returns [code]false[/code], if the sprite's texture is [code]null[/code] or if the given position is invalid.
func (Instance) OnFrameChanged ¶
func (Instance) OnTextureChanged ¶
func (Instance) RegionEnabled ¶
func (Instance) RegionFilterClipEnabled ¶
func (Instance) RegionRect ¶
func (self Instance) RegionRect() Rect2.PositionSize
func (Instance) SetCentered ¶
func (Instance) SetFrameCoords ¶
func (Instance) SetHframes ¶
func (Instance) SetRegionEnabled ¶
func (Instance) SetRegionFilterClipEnabled ¶
func (Instance) SetRegionRect ¶
func (self Instance) SetRegionRect(value Rect2.PositionSize)