Class Sprite_CB_GB_Extension
- Namespace
- Godot
- Assembly
- com.cobilas.godot.utility.dll
Provides extension methods for Godot's Sprite class, allowing more convenient operations with 2D rectangles (Rect2D).
public static class Sprite_CB_GB_Extension
- Inheritance
-
Sprite_CB_GB_Extension
- Inherited Members
Remarks
This class facilitates conversion between Godot.Sprite properties and the custom Rect2D type, for both local and global coordinates.
Methods
GetGlobalRect2D(Sprite?)
Gets a Rect2D representing the global rectangle of the Godot.Control.
public static Rect2D GetGlobalRect2D(this Sprite? ctl)
Parameters
ctlSpriteGodot.Control target (can be null)
Returns
- Rect2D
A Rect2D containing the global position, size, rotation, scale, and pivot of the Godot.Control
Exceptions
- ArgumentNullException
Thrown when Godot.Control is null
GetRect2D(Sprite?)
Gets a Rect2D representing the local rectangle of the Godot.Control.
public static Rect2D GetRect2D(this Sprite? ctl)
Parameters
ctlSpriteGodot.Control target (can be null)
Returns
Exceptions
- ArgumentNullException
Thrown when Godot.Control is null
GetTextureSize(Sprite?)
Gets the scaled texture size of the Godot.Sprite.
public static Vector2D GetTextureSize(this Sprite? ctl)
Parameters
ctlSpriteGodot.Sprite target (can be null)
Returns
Exceptions
- ArgumentNullException
Thrown when Godot.Sprite is null
SetGlobalRect2D(Sprite?, Rect2D)
Sets the properties of the Godot.Control based on a Rect2D, using global coordinates.
public static void SetGlobalRect2D(this Sprite? ctl, Rect2D rect)
Parameters
ctlSpriteGodot.Control target (can be null)
rectRect2DRect2D containing the global properties to be applied
Exceptions
- ArgumentNullException
Thrown when Godot.Control is null
SetRect2D(Sprite?, Rect2D)
Sets the properties of the Godot.Control based on a Rect2D.
public static void SetRect2D(this Sprite? ctl, Rect2D rect)
Parameters
ctlSpriteGodot.Control target (can be null)
rectRect2DRect2D contendo as propriedades a serem aplicadas
Exceptions
- ArgumentNullException
Thrown when Godot.Control is null
SetTextureSize(Sprite?, Vector2DInt)
Sets the texture size of the Godot.Sprite by adjusting its scale.
public static void SetTextureSize(this Sprite? ctl, Vector2DInt newSize)
Parameters
ctlSpriteGodot.Sprite target (can be null)
newSizeVector2DIntThe desired texture size as a Vector2DInt
Remarks
This method calculates and applies the appropriate scale to achieve the desired texture size. If the sprite's texture is null, the method returns without making changes.
Exceptions
- ArgumentNullException
Thrown when Godot.Sprite is null