Struct Sprite

General-purpose sprite node.

struct Sprite ;

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.

Properties

NameTypeDescription
centered[get, set] boolIf true, texture is centered.
flipH[get, set] boolIf true, texture is flipped horizontally.
flipV[get, set] boolIf true, texture is flipped vertically.
frame[get, set] longCurrent frame to display from sprite sheet. vframes or hframes must be greater than 1.
frameCoords[get, set] Vector2Coordinates 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.
hframes[get, set] longThe number of columns in the sprite sheet.
normalMap[get, set] TextureThe normal map gives depth to the Sprite.
offset[get, set] Vector2The texture's drawing offset.
regionEnabled[get, set] boolIf true, texture is cut from a larger atlas texture. See regionRect.
regionFilterClip[get, set] boolIf true, the outermost pixels get blurred out.
regionRect[get, set] Rect2The region of the atlas texture to display. regionEnabled must be true.
texture[get, set] TextureTexture object to draw.
vframes[get, set] longThe number of rows in the sprite sheet.

Methods

NameDescription
_textureChanged
getFrame
getFrameCoords
getHframes
getNormalMap
getOffset
getRect Returns a Rect2 representing the Sprite's boundary in local coordinates. Can be used to detect if the Sprite was clicked. Example:
getRegionRect
getTexture
getVframes
isCentered
isFlippedH
isFlippedV
isPixelOpaque 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.
isRegion
isRegionFilterClipEnabled
setCentered
setFlipH
setFlipV
setFrame
setFrameCoords
setHframes
setNormalMap
setOffset
setRegion
setRegionFilterClip
setRegionRect
setTexture
setVframes