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.
  • loaded Boolean Whether the asset is loaded or not
  • nativeUrl String Returns the url of this asset's native object, if none it will returns an empty string.
  • _native String Serializable url for native asset.
  • _nativeAsset Object The underlying native asset of this asset if one is available.
  • _uuid String
  • _name String
  • _objFlags Number
  • name String The name of the object.
  • isValid Boolean Indicates whether the object is not yet destroyed.
Methods

Details

Properties

duration

Duration of this animation.

meta description
Type Number
Defined in cocos2d/animation/animation-clip.js:46
sample

FrameRate of this animation.

meta description
Type Number
Defined in cocos2d/animation/animation-clip.js:56
speed

Speed of this animation.

meta description
Type Number
Defined in cocos2d/animation/animation-clip.js:66
wrapMode

WrapMode of this animation.

meta description
Type WrapMode
Defined in cocos2d/animation/animation-clip.js:76
curveData

Curve data.

meta description
Type Object
Defined in cocos2d/animation/animation-clip.js:86
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 cocos2d/animation/animation-clip.js:98
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'] }
]
loaded

Whether the asset is loaded or not

meta description
Type Boolean
Defined in cocos2d/core/assets/CCAsset.js:57
nativeUrl

Returns the url of this asset's native object, if none it will returns an empty string.

meta description
Type String
Defined in cocos2d/core/assets/CCAsset.js:70
_native

Serializable url for native asset.

meta description
Type String
Defined in cocos2d/core/assets/CCAsset.js:108
_nativeAsset

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.

meta description
Type Object
Defined in cocos2d/core/assets/CCAsset.js:116
_uuid
meta description
Type String
Defined in cocos2d/core/assets/CCRawAsset.js:46
_name
meta description
Type String
Defined in cocos2d/core/platform/CCObject.js:76
_objFlags
meta description
Type Number
Defined in cocos2d/core/platform/CCObject.js:83
name

The name of the object.

meta description
Type String
Defined in cocos2d/core/platform/CCObject.js:243
Examples
obj.name = "New Obj";
isValid

Indicates whether the object is not yet destroyed. (It will not be available after being destroyed)
When an object's destroy is called, it is actually destroyed after the end of this frame. So isValid will return false from the next frame, while isValid in the current frame will still be true. If you want to determine whether the current frame has called destroy, use cc.isValid(obj, true), but this is often caused by a particular logical requirements, which is not normally required.

meta description
Type Boolean
Defined in cocos2d/core/platform/CCObject.js:261
Examples
var node = new cc.Node();
cc.log(node.isValid);    // true
node.destroy();
cc.log(node.isValid);    // true, still valid in this frame
// after a frame...
cc.log(node.isValid);    // false, destroyed in the end of last frame

Methods

createWithSpriteFrames

Crate clip with a set of sprite frames

meta description
Returns AnimationClip
Defined in cocos2d/animation/animation-clip.js:113
Parameters
Examples
var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10);
toString

Returns the asset's url.

The Asset object overrides the toString() method of the Object object. For Asset objects, the toString() method returns a string representation of the 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.

meta description
Returns String
Defined in cocos2d/core/assets/CCAsset.js:169
serialize

应 AssetDB 要求提供这个方法

meta description
Returns String
Defined in cocos2d/core/assets/CCAsset.js:183
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 cocos2d/core/assets/CCAsset.js:194
Parameters
_setRawAsset

Set native file name for this asset.

meta description
Defined in cocos2d/core/assets/CCAsset.js:209
Parameters
destroy

Destroy this Object, and release all its own references to other objects.
Actual object destruction will delayed until before rendering. From the next frame, this object 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 cocos2d/core/platform/CCObject.js:296
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 cocos2d/core/platform/CCObject.js:430
_onPreDestroy

Called before the object being destroyed.

meta description
Defined in cocos2d/core/platform/CCObject.js:463
_serialize

The customized serialization for this object. (Editor Only)

meta description
Returns object
Defined in cocos2d/core/platform/CCObject.js:488
Parameters
_deserialize

Init this object from the custom serialized data.

meta description
Defined in cocos2d/core/platform/CCObject.js:498
Parameters
  • data Object the serialized json data
  • ctx _Deserializer

results matching ""

    No results matching ""