Serializable url for native asset. For internal usage.
Whether the asset is loaded or not
UV for quad vertices
UV for sliced 9 vertices
Vertex list for the mesh type sprite frame
Indicates whether its dependent native assets can support deferred load if the owner scene (or prefab) is marked as asyncLoadAssets
.
Indicates whether its native object should be preloaded from native url.
The underlying native asset of this asset if one is available.
This property can be used to access additional details or functionality releated to the asset.
This property will be initialized by the loader if _native
is available.
The underlying native asset of this asset if one is available.
This property can be used to access additional details or functionality releated to the asset.
This property will be initialized by the loader if _native
is available.
The uuid of the atlas asset, if exist
The uuid of the atlas asset, if exist
Whether flip the uv in X direction
Whether flip the uv in X direction
Whether flip the uv in Y direction
Whether flip the uv in Y direction
The pixel height of the sprite frame
Bottom border distance of sliced 9 rect.
Bottom border distance of sliced 9 rect.
Left border distance of sliced 9 rect.
Left border distance of sliced 9 rect.
Right border distance of sliced 9 rect.
Right border distance of sliced 9 rect.
Top border distance of sliced 9 rect.
Top border distance of sliced 9 rect.
Returns the url of this asset's native object, if none it will returns an empty string.
The offset of the sprite frame center. Sprite frame in an atlas texture could be trimmed for clipping the transparent pixels, so the trimmed rect is smaller than the original one, the offset defines the distance from the original center to the trimmed center.
The offset of the sprite frame center. Sprite frame in an atlas texture could be trimmed for clipping the transparent pixels, so the trimmed rect is smaller than the original one, the offset defines the distance from the original center to the trimmed center.
Returns the rect of the sprite frame in the texture. If it's an atlas texture, a transparent pixel area is proposed for the actual mapping of the current texture.
Returns the rect of the sprite frame in the texture. If it's an atlas texture, a transparent pixel area is proposed for the actual mapping of the current texture.
The number of reference
Whether the content of sprite frame is rotated.
Whether the content of sprite frame is rotated.
The texture of the sprite frame, could be TextureBase or RenderTexture
The texture of the sprite frame, could be TextureBase or RenderTexture
The pixel width of the sprite frame
Set native file name for this asset.
Add references of asset
itself
Check whether the rect of the sprite frame is out of the texture boundary
Create a new node using this asset in the scene.
If this type of asset dont have its corresponding node type, this method should be null.
Reduce references of asset and it will be auto released when refCount equals 0.
itself
Gets the sampler resource of its texture
Gets the hash of its texture
Gets the sampler hash of its texture
Returns whether the sprite frame is rotated in the texture.
Resets the sprite frame data
SpriteFrame initialization information
应 AssetDB 要求提供这个方法。 返回一个序列化后的对象
Sets the offset of the frame
The new offset
Sets the original size before trimmed.
The new original size
Sets the rect of the sprite frame in the texture.
Set whether the sprite frame is rotated in the texture.
Returns whether the texture have been loaded.
Returns the string representation of the object.
The Asset
object overrides the toString()
method of the Object
object.
JavaScript calls the toString() method automatically
when an asset is to be represented as a text value or when a texture is referred to in a string concatenation.
For assets of the native type, it will return this.nativeUrl
.
Otherwise, an empty string is returned.
This method may be overwritten by subclasses.
Create a SpriteFrame object by an image asset or an native image asset
ImageAsset or ImageSource, ImageSource support HTMLCanvasElement HTMLImageElement IMemoryImageSource
应 AssetDB 要求提供这个方法。
Generated using TypeDoc
A
SpriteFrame
support several typesimport { resources } from 'cc'; // First way to use a SpriteFrame const url = "assets/PurpleMonster/icon/spriteFrame"; resources.load(url, (err, spriteFrame) => { const node = new Node("New Sprite"); const sprite = node.addComponent(Sprite); sprite.spriteFrame = spriteFrame; node.parent = self.node; }); // Second way to use a SpriteFrame const self = this; const url = "test_assets/PurpleMonster"; resources.load(url, (err, imageAsset) => { if(err){ return; } const node = new Node("New Sprite"); const sprite = node.addComponent(Sprite); const spriteFrame = new SpriteFrame(); const tex = imageAsset._texture; spriteFrame.texture = tex; sprite.spriteFrame = spriteFrame; node.parent = self.node; }); // Third way to use a SpriteFrame const self = this; const cameraComp = this.getComponent(Camera); const renderTexture = new RenderTexture(); rendetTex.reset({ width: 512, height: 512, depthStencilFormat: RenderTexture.DepthStencilFormat.DEPTH_24_STENCIL_8 }); cameraComp.targetTexture = renderTexture; const spriteFrame = new SpriteFrame(); spriteFrame.texture = renderTexture;