Tween Class
Module: cc
Tween provide a simple and flexible way to create action. Tween's api is more flexible than cc.Action:
- Support creating an action sequence in chained api,
- Support animate any objects' any properties, not limited to node's properties. By contrast, cc.Action needs to create a new action class to support new node property.
- Support working with cc.Action,
- Support easing and progress function.
Examples
cc.tween(node)
.to(1, {scale: 2, position: cc.v3(100, 100, 100)})
.call(() => { console.log('This is a callback'); })
.by(1, {scale: 3, position: cc.v3(200, 200, 200)}, {easing: 'sineOutIn'})
.start(cc.find('Canvas/cocos'));
Index
Methods
constructorstopAllStop all tweensstopAllByTagStop all tweens by tagstopAllByTargetStop all tweens by targetthenInsert an action or tween to this sequencetargetSet tween targetstartStart this tweenstopStop this tweentagSets tween tagcloneClone a tweenunionIntegrate all previous actions to an action.bezierToSets target's position property according to the bezier curve.bezierBySets target's position property according to the bezier curve.flipXFlips target's scaleXflipYFlips target's scaleYblinkBlinks target by set target's opacity propertytoAdd an action which calculate with absolute valuebyAdd an action which calculate with relative valuesetDirectly set target propertiesdelayAdd an delay actioncallAdd an callback actionhideAdd an hide actionshowAdd an show actionremoveSelfAdd an removeSelf actionsequenceAdd an sequence actionparallelAdd an parallel actionrepeatAdd an repeat action.repeatForeverAdd an repeat forever actionreverseTimeAdd an reverse time action.
Details
Methods
constructor
| meta | description |
|---|---|
| Defined in | cocos2d/actions/tween.js:181 |
Parameters
targetObject
stopAll
Stop all tweens
| meta | description |
|---|---|
| Defined in | cocos2d/actions/tween.js:186 |
stopAllByTag
Stop all tweens by tag
| meta | description |
|---|---|
| Defined in | cocos2d/actions/tween.js:195 |
Parameters
tagnumber
stopAllByTarget
Stop all tweens by target
| meta | description |
|---|---|
| Defined in | cocos2d/actions/tween.js:205 |
Parameters
targetObject
then
Insert an action or tween to this sequence
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:216 |
Parameters
target
Set tween target
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:236 |
Parameters
targetObject
start
Start this tween
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:250 |
stop
Stop this tween
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:282 |
tag
Sets tween tag
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:298 |
Parameters
tagnumber
clone
Clone a tween
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:311 |
Parameters
targetObject
union
Integrate all previous actions to an action.
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:325 |
bezierTo
Sets target's position property according to the bezier curve.
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:354 |
Parameters
durationnumberc1cc.Vec2c2cc.Vec2tocc.Vec2
bezierBy
Sets target's position property according to the bezier curve.
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:376 |
Parameters
durationnumberc1cc.Vec2c2cc.Vec2tocc.Vec2
flipX
Flips target's scaleX
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:399 |
flipY
Flips target's scaleY
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:408 |
blink
Blinks target by set target's opacity property
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:418 |
Parameters
to
Add an action which calculate with absolute value
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:462 |
Parameters
by
Add an action which calculate with relative value
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:483 |
Parameters
set
Directly set target properties
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:504 |
Parameters
propsObject
delay
Add an delay action
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:519 |
Parameters
durationNumber
call
Add an callback action
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:529 |
Parameters
callbackFunction
hide
Add an hide action
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:539 |
show
Add an show action
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:548 |
removeSelf
Add an removeSelf action
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:557 |
sequence
Add an sequence action
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:566 |
Parameters
parallel
Add an parallel action
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:577 |
Parameters
repeat
Add an repeat action. This action will integrate before actions to a sequence action as their parameters.
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:592 |
Parameters
repeatForever
Add an repeat forever action This action will integrate before actions to a sequence action as their parameters.
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:604 |
Parameters
reverseTime
Add an reverse time action. This action will integrate before actions to a sequence action as their parameters.
| meta | description |
|---|---|
| Returns | Tween |
| Defined in | cocos2d/actions/tween.js:618 |