cocos2d-js: ease action in javascript code example

2.1k views Asked by At

I want to use 'Ease' action in cocos2d-js (javascript language) but there is only info in c++ language. Can you help me by showing me some example codes?

Detail:

  1. Move, Rotate, Scale actions I am using.
  2. I am using all of this in SPAWN action.
  3. I want to make this SPAWN ACTION 'ease's.

Example code please. Thanks in advance.

1

There are 1 answers

0
Alex G. G. On

http://www.cocos2d-x.org/reference/html5-js/V3.6/index.html

If you go

cc.Class -> cc.Action -> cc.FiniteTimeAction -> cc.ActionInterval -> cc.ActionEase

There there are all the easings with examples in the doc but it goes like this:

var actionMove = cc.move(...).easing(cc.easeBackIn()); (or your easing function you feel like to use)
var actionRotate = cc.rotate(...).easing(cc.easeBackIn()); (or your easing function you feel like to use)
var actionScale = cc.scale(...).easing(cc.easeBackIn()); (or your easing function you feel like to use).

this.runAction(cc.spawn(actionMove, actionScale, actionRotate));

Hope it helps