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
Name | Type | Description |
---|---|---|
centered [get, set]
|
bool | If true , texture is centered.
|
flipH [get, set]
|
bool | If true , texture is flipped horizontally.
|
flipV [get, set]
|
bool | If true , texture is flipped vertically.
|
frame [get, set]
|
long | Current frame to display from sprite sheet. vframes or hframes must be greater than 1.
|
frameCoords [get, set]
|
Vector2 | 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.
|
hframes [get, set]
|
long | The number of columns in the sprite sheet. |
normalMap [get, set]
|
Texture | The normal map gives depth to the Sprite. |
offset [get, set]
|
Vector2 | The texture's drawing offset. |
regionEnabled [get, set]
|
bool | If true , texture is cut from a larger atlas texture. See regionRect .
|
regionFilterClip [get, set]
|
bool | If true , the outermost pixels get blurred out.
|
regionRect [get, set]
|
Rect2 | The region of the atlas texture to display. regionEnabled must be true .
|
texture [get, set]
|
Texture | Texture object to draw.
|
vframes [get, set]
|
long | The number of rows in the sprite sheet. |
Methods
Name | Description |
---|---|
_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
|