Skip to content

Sprite

继承自 AssetObject

Sprite类主要用于在 2D 游戏中表示图像。它封装了与 2D 图像相关的所有数据和方法,使得在 2D 游戏开发中处理精灵(Sprite)变得更加方便。

javascript
    let sprite = Resources.Load(Sprite, "spriteID");
    if (sprite == null){
        throw new Exception("failed to load sprite: " + uuid);
    }

成员变量

Sprite.spriteRect : Rect
(只读)sprite 在原始纹理中的位置(以像素为单位指定)。
Sprite.spriteUV : Rect
(只读)sprite相关的 UV 坐标。
Sprite.pivot : Vector2
sprite 的枢轴点。