SpriteAtlas Class
Extends RawAsset
Module: cc
Class for sprite atlas handling.
Index
Properties
- _uuid- String
- _name- String
- _objFlags- Number
- name- StringThe name of the object.
- isValid- BooleanIndicates whether the object is not yet destroyed.
Methods
- getTextureReturns the texture of the sprite atlas
- getSpriteFrameReturns the sprite frame correspond to the given key in sprite atlas.
- getSpriteFramesReturns the sprite frames in sprite atlas.
- destroyDestroy this Object, and release all its own references to other objects.
 Actual object destruction will delayed until before rendering.
 After destroy, this CCObject is not usable any more. You can use cc.isValid(obj) to check whether the object is destroyed before accessing it.
- _destructClear all references in the instance.
NOTE: this method will not clear the getter or setter functions which defined in the instance of CCObject. You can override the _destruct method if you need, for example: _destruct: function () { for (var key in this) { if (this.hasOwnProperty(key)) { switch (typeof this[key]) { case 'string': this[key] = ''; break; case 'object': case 'function': this[key] = null; break; } } }
- _onPreDestroyCalled before the object being destroyed.
- _serializeThe customized serialization for this object. (Editor Only)
- _deserializeInit this object from the custom serialized data.
Details
Properties
_uuid
| meta | description | 
|---|---|
| Type | String | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/assets/CCRawAsset.js:49 | 
_name
| meta | description | 
|---|---|
| Type | String | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCObject.js:50 | 
_objFlags
| meta | description | 
|---|---|
| Type | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCObject.js:57 | 
name
The name of the object.
| meta | description | 
|---|---|
| Type | String | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCObject.js:208 | 
Examples
obj.name = "New Obj";
isValid
Indicates whether the object is not yet destroyed.
| meta | description | 
|---|---|
| Type | Boolean | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCObject.js:225 | 
Examples
cc.log(obj.isValid);
Methods
getTexture
Returns the texture of the sprite atlas
| meta | description | 
|---|---|
| Returns | Texture2D | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/assets/CCSpriteAtlas.js:45 | 
getSpriteFrame
Returns the sprite frame correspond to the given key in sprite atlas.
| meta | description | 
|---|---|
| Returns | SpriteFrame | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/assets/CCSpriteAtlas.js:61 | 
Parameters
- keyString
getSpriteFrames
Returns the sprite frames in sprite atlas.
| meta | description | 
|---|---|
| Returns | [SpriteFrame] | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/assets/CCSpriteAtlas.js:71 | 
destroy
Destroy this Object, and release all its own references to other objects.
Actual object destruction will delayed until before rendering.
After destroy, this CCObject is not usable any more.
You can use cc.isValid(obj) to check whether the object is destroyed before accessing it.
| meta | description | 
|---|---|
| Returns | Boolean | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCObject.js:246 | 
Examples
obj.destroy();
_destruct
Clear all references in the instance.
NOTE: this method will not clear the getter or setter functions which defined in the instance of CCObject. You can override the _destruct method if you need, for example: _destruct: function () { for (var key in this) { if (this.hasOwnProperty(key)) { switch (typeof this[key]) { case 'string': this[key] = ''; break; case 'object': case 'function': this[key] = null; break; } } }
| meta | description | 
|---|---|
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCObject.js:379 | 
_onPreDestroy
Called before the object being destroyed.
| meta | description | 
|---|---|
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCObject.js:412 | 
_serialize
The customized serialization for this object. (Editor Only)
| meta | description | 
|---|---|
| Returns | object | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCObject.js:437 | 
Parameters
- exportingBoolean
_deserialize
Init this object from the custom serialized data.
| meta | description | 
|---|---|
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCObject.js:447 | 
Parameters
- dataObject the serialized json data
- ctx_Deserializer
