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'})
.run(cc.find('Canvas/cocos'));
Index
Methods
then
Insert an action or tween to this sequencetarget
Set tween targetstart
Start this tweenstop
Stop this tweenclone
Clone a tweenunion
Integrate all previous actions to an action.to
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 actionreverseTime
Add an reverse time action.
Details
Methods
then
Insert an action or tween to this sequence
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:178 |
Parameters
target
Set tween target
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:198 |
Parameters
target
Object
start
Start this tween
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:212 |
stop
Stop this tween
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:233 |
clone
Clone a tween
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:250 |
Parameters
target
Object
union
Integrate all previous actions to an action.
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:264 |
to
Add an action which calculate with absolute value
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:309 |
Parameters
by
Add an action which calculate with relative value
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:328 |
Parameters
set
Directly set target properties
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:347 |
Parameters
props
Object
delay
Add an delay action
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:360 |
Parameters
duration
Number
call
Add an callback action
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:370 |
Parameters
callback
Function
hide
Add an hide action
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:380 |
show
Add an show action
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:389 |
removeSelf
Add an removeSelf action
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:398 |
sequence
Add an sequence action
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:407 |
Parameters
parallel
Add an parallel action
meta | description |
---|---|
Returns | Tween |
Defined in | cocos2d/actions/tween.js:418 |
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:433 |
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:445 |
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:459 |