General-purpose sprite node.
    public class Sprite : Node2D

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.

Inheritance Chain

Constructors

    public Sprite()

Signals

    "frame_changed" ()

Emitted when the Frame changes.

    "texture_changed" ()

Emitted when the Texture changes.

Properties

    public bool Centered { get; set; }

If true, texture is centered.

    public bool FlipH { get; set; }

If true, texture is flipped horizontally.

    public bool FlipV { get; set; }

If true, texture is flipped vertically.

    public int Frame { get; set; }

Current frame to display from sprite sheet. Vframes or Hframes must be greater than 1.

    public Vector2 FrameCoords { get; set; }

Coordinates of the frame to display from sprite sheet. This is as an alias for the Frame property. Vframes or Hframes must be greater than 1.

    public int Hframes { get; set; }

The number of columns in the sprite sheet.

    public Texture NormalMap { get; set; }

The normal map gives depth to the Sprite.

    public Vector2 Offset { get; set; }

The texture’s drawing offset.

    public bool RegionEnabled { get; set; }

If true, texture is cut from a larger atlas texture. See RegionRect.

    public bool RegionFilterClip { get; set; }

If true, the outermost pixels get blurred out.

    public Rect2 RegionRect { get; set; }

The region of the atlas texture to display. RegionEnabled must be true.

    public Texture Texture { get; set; }

Texture object to draw.

    public int Vframes { get; set; }

The number of rows in the sprite sheet.

Methods

    [Obsolete("GetFrame is deprecated. Use the Frame property instead.")]
    public int GetFrame()

Getter for Frame

    [Obsolete("GetFrameCoords is deprecated. Use the FrameCoords property instead.")]
    public Vector2 GetFrameCoords()

Getter for FrameCoords

    [Obsolete("GetHframes is deprecated. Use the Hframes property instead.")]
    public int GetHframes()

Getter for Hframes

    [Obsolete("GetNormalMap is deprecated. Use the NormalMap property instead.")]
    public Texture GetNormalMap()

Getter for NormalMap

    [Obsolete("GetOffset is deprecated. Use the Offset property instead.")]
    public Vector2 GetOffset()

Getter for Offset

    public Rect2 GetRect()

Returns a Rect2 representing the Sprite’s boundary in local coordinates. Can be used to detect if the Sprite was clicked. Example:

[codeblock]

func _input(event):

if event is InputEventMouseButton and event.pressed and event.button_index == BUTTON_LEFT:

if get_rect().has_point(to_local(event.position)):

print(“A click!”)

[/codeblock]

    [Obsolete("GetRegionRect is deprecated. Use the RegionRect property instead.")]
    public Rect2 GetRegionRect()

Getter for RegionRect

    [Obsolete("GetTexture is deprecated. Use the Texture property instead.")]
    public Texture GetTexture()

Getter for Texture

    [Obsolete("GetVframes is deprecated. Use the Vframes property instead.")]
    public int GetVframes()

Getter for Vframes

    [Obsolete("IsCentered is deprecated. Use the Centered property instead.")]
    public bool IsCentered()

Getter for Centered

    [Obsolete("IsFlippedH is deprecated. Use the FlipH property instead.")]
    public bool IsFlippedH()

Getter for FlipH

    [Obsolete("IsFlippedV is deprecated. Use the FlipV property instead.")]
    public bool IsFlippedV()

Getter for FlipV

    public bool IsPixelOpaque(Vector2 pos)

Returns true, if the pixel at the given position is opaque and false in other case.

Note: It also returns false, if the sprite’s texture is null or if the given position is invalid.

    [Obsolete("IsRegion is deprecated. Use the RegionEnabled property instead.")]
    public bool IsRegion()

Getter for RegionEnabled

    [Obsolete("IsRegionFilterClipEnabled is deprecated. Use the RegionFilterClip property instead.")]
    public bool IsRegionFilterClipEnabled()

Getter for RegionFilterClip

    [Obsolete("SetCentered is deprecated. Use the Centered property instead.")]
    public void SetCentered(bool centered)

Setter for Centered

    [Obsolete("SetFlipH is deprecated. Use the FlipH property instead.")]
    public void SetFlipH(bool flipH)

Setter for FlipH

    [Obsolete("SetFlipV is deprecated. Use the FlipV property instead.")]
    public void SetFlipV(bool flipV)

Setter for FlipV

    [Obsolete("SetFrame is deprecated. Use the Frame property instead.")]
    public void SetFrame(int frame)

Setter for Frame

    [Obsolete("SetFrameCoords is deprecated. Use the FrameCoords property instead.")]
    public void SetFrameCoords(Vector2 coords)

Setter for FrameCoords

    [Obsolete("SetHframes is deprecated. Use the Hframes property instead.")]
    public void SetHframes(int hframes)

Setter for Hframes

    [Obsolete("SetNormalMap is deprecated. Use the NormalMap property instead.")]
    public void SetNormalMap(Texture normalMap)

Setter for NormalMap

    [Obsolete("SetOffset is deprecated. Use the Offset property instead.")]
    public void SetOffset(Vector2 offset)

Setter for Offset

    [Obsolete("SetRegion is deprecated. Use the RegionEnabled property instead.")]
    public void SetRegion(bool enabled)

Setter for RegionEnabled

    [Obsolete("SetRegionFilterClip is deprecated. Use the RegionFilterClip property instead.")]
    public void SetRegionFilterClip(bool enabled)

Setter for RegionFilterClip

    [Obsolete("SetRegionRect is deprecated. Use the RegionRect property instead.")]
    public void SetRegionRect(Rect2 rect)

Setter for RegionRect

    [Obsolete("SetTexture is deprecated. Use the Texture property instead.")]
    public void SetTexture(Texture texture)

Setter for Texture

    [Obsolete("SetVframes is deprecated. Use the Vframes property instead.")]
    public void SetVframes(int vframes)

Setter for Vframes

Tags: