AnimationClip Class

Extends Asset

Module: cc

Class for animation data handling.

Index

Properties
  • duration Number Duration of this animation.
  • sample Number FrameRate of this animation.
  • speed Number Speed of this animation.
  • wrapMode WrapMode WrapMode of this animation.
  • curveData Object Curve data.
  • events Object[] Event data.
  • rawUrl String Returns the url of this asset's first raw file, if none of rawFile exists, it will returns an empty string.
  • rawUrls String[] Returns the url of this asset's raw files, if none of rawFile exists, it will returns an empty array.
  • _rawFiles String[] 在 lite 版的 Fireball 里,raw asset 并不仅仅是在 properties 里声明了 rawType 才有, 而是每个 asset 都能指定自己的 raw file url。这些 url 就存在 _rawFiles 字段中。 AssetLibrary 并不会帮你加载这些 url,除非你声明了 rawType。 在 Creator 里,_rawFiles 保留了下来,为了复用 cocos 引擎原有实现,直接用 _rawFiles 来加载 Asset 在 import 之前的源文件。
  • _uuid String
  • _name String
  • _objFlags Number
  • name String The name of the object.
  • isValid Boolean Indicates whether the object is not yet destroyed.
Methods
  • createWithSpriteFrames Crate clip with a set of sprite frames
  • serialize 应 AssetDB 要求提供这个方法
  • createNode 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.
  • _setRawFiles Set raw file names for this asset.
  • _preloadRawFiles Preload raw files when loading scene.
  • 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.
  • _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; } } }

  • _onPreDestroy Called before the object being destroyed.
  • _serialize The customized serialization for this object. (Editor Only)
  • _deserialize Init this object from the custom serialized data.

Details

Properties

duration

Duration of this animation.

meta description
Type Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/animation/animation-clip.js:21
sample

FrameRate of this animation.

meta description
Type Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/animation/animation-clip.js:31
speed

Speed of this animation.

meta description
Type Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/animation/animation-clip.js:41
wrapMode

WrapMode of this animation.

meta description
Type WrapMode
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/animation/animation-clip.js:51
curveData

Curve data.

meta description
Type Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/animation/animation-clip.js:61
Examples
{
    // 根节点不用查找路径
    // root properties
    props: {
        x: [
            { frame: 0, value: 0, curve: [0,0.5,0.5,1] },
            { frame: 1, value: 200, curve: null }
        ]
    },
    comps: {
        // component
        'comp-1': {
            // component properties
            'prop-1': [
                { frame: 0, value: 10, curve: [0,0.5,0.5,1] },
                { frame: 1, value: 20, curve: null }
            ]
        }
    },
    paths: {
        // key 为节点到root的路径名, 通过cc.find找到
        'foo/bar': {
            // node properties
            props: {
                x: [
                    { frame: 0, value: 0, curve: [0,0.5,0.5,1]
                    { frame: 1, value: 200, curve: null }
                ]
            },
            comps: {
                // component
                'comp-1': {
                    // component property
                    'prop-1': [
                        { frame: 0, value: 10, curve: [0,0.5,0.
                            { frame: 1, value: 20, curve: null }
                        ]
                        }
                }
            },
            'hello': {
                props: {
                    position: [
                        {
                            frame: 0,
                            value: [0,0],
                            motionPath: [
                                [320, 240, 0, 240, 640, 240],
                                [640, 0, 400, 0, 1000, 0]
                            ]
                        },
                        { frame: 5, value: [640, 480] }
                    ]
                }
            }
        }
    }
}
events

Event data.

meta description
Type Object[]
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/animation/animation-clip.js:73
Examples
// frame    : The exactly time in second.
// func     : Callback function name
// params   : Callback parameters
[
    { frame: 0, func: 'onAnimationEvent1', params:['param-1', 'param-2'] },
    { frame: 2, func: 'onAnimationEvent3', params:['param-1', 'param-2'] },
    { frame: 3, func: 'onAnimationEvent2', params:['param-1'] },
    // The second event at frame 3
    { frame: 3, func: 'onAnimationEvent4', params:['param-1'] },
    { frame: 4, func: 'onAnimationEvent4', params:['param-1'] }
]
rawUrl

Returns the url of this asset's first raw file, if none of rawFile exists, it will returns an empty string.

meta description
Type String
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/assets/CCAsset.js:53
rawUrls

Returns the url of this asset's raw files, if none of rawFile exists, it will returns an empty array.

meta description
Type String[]
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/assets/CCAsset.js:77
_rawFiles

在 lite 版的 Fireball 里,raw asset 并不仅仅是在 properties 里声明了 rawType 才有, 而是每个 asset 都能指定自己的 raw file url。这些 url 就存在 _rawFiles 字段中。 AssetLibrary 并不会帮你加载这些 url,除非你声明了 rawType。 在 Creator 里,_rawFiles 保留了下来,为了复用 cocos 引擎原有实现,直接用 _rawFiles 来加载 Asset 在 import 之前的源文件。

meta description
Type String[]
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/assets/CCAsset.js:104
_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

createWithSpriteFrames

Crate clip with a set of sprite frames

meta description
Returns AnimationClip
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/animation/animation-clip.js:88
Parameters
Examples
var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10);
serialize

应 AssetDB 要求提供这个方法

meta description
Returns String
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/assets/CCAsset.js:143
createNode

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.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/assets/CCAsset.js:154
Parameters
_setRawFiles

Set raw file names for this asset.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/assets/CCAsset.js:168
Parameters
_preloadRawFiles

Preload raw files when loading scene.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/assets/CCAsset.js:179
Parameters
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
_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
  • data Object the serialized json data
  • ctx _Deserializer

results matching ""

    No results matching ""