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
constructor
stopAll
Stop all tweensstopAllByTag
Stop all tweens by tagstopAllByTarget
Stop all tweens by targetthen
Insert an action or tween to this sequencetarget
Set tween targetstart
Start this tweenstop
Stop this tweentag
Sets tween tagclone
Clone a tweenunion
Integrate all previous actions to an action.bezierTo
Sets target's position property according to the bezier curve.bezierBy
Sets target's position property according to the bezier curve.flipX
Flips target's scaleXflipY
Flips target's scaleYblink
Blinks target by set target's opacity propertyto
Add an action which calculate with absolute valueby
Add an action which calculate with relative valueset
Directly set target propertiesdelay
Add an delay actioncall
Add an callback actionhide
Add an hide actionshow
Add an show actionremoveSelf
Add an removeSelf actionsequence
Add an sequence actionparallel
Add an parallel actionrepeat
Add an repeat action.repeatForever
Add an repeat forever action.reverseTime
Add an reverse time action.
Details
Methods
constructor
meta | description |
---|---|
Defined in | cocos2d/actions/tween.js:184 |
Parameters
target
Object
stopAll
Stop all tweens
meta | description |
---|---|
Defined in | cocos2d/actions/tween.js:189 |
stopAllByTag
Stop all tweens by tag
meta | description |
---|---|
Defined in | cocos2d/actions/tween.js:198 |
Parameters
tag
number
stopAllByTarget
Stop all tweens by target
meta | description |
---|---|
Defined in | cocos2d/actions/tween.js:208 |
Parameters
target
Object
then
Insert an action or tween to this sequence
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:219 |
Parameters
target
Set tween target
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:240 |
Parameters
target
Object
start
Start this tween
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:255 |
stop
Stop this tween
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:288 |
tag
Sets tween tag
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:306 |
Parameters
tag
number
clone
Clone a tween
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:320 |
Parameters
target
Object
union
Integrate all previous actions to an action.
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:335 |
bezierTo
Sets target's position property according to the bezier curve.
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:365 |
Parameters
duration
numberc1
cc.Vec2c2
cc.Vec2to
cc.Vec2
bezierBy
Sets target's position property according to the bezier curve.
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:388 |
Parameters
duration
numberc1
cc.Vec2c2
cc.Vec2to
cc.Vec2
flipX
Flips target's scaleX
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:412 |
flipY
Flips target's scaleY
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:423 |
blink
Blinks target by set target's opacity property
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:434 |
Parameters
to
Add an action which calculate with absolute value
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:479 |
Parameters
by
Add an action which calculate with relative value
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:500 |
Parameters
set
Directly set target properties
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:521 |
Parameters
props
Object
delay
Add an delay action
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:536 |
Parameters
duration
Number
call
Add an callback action
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:547 |
Parameters
hide
Add an hide action
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:559 |
show
Add an show action
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:569 |
removeSelf
Add an removeSelf action
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:579 |
sequence
Add an sequence action
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:589 |
Parameters
parallel
Add an parallel action
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:601 |
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:617 |
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:629 |
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:640 |