Theoretical part
A time interval action (Actioninterval) is an action performed over a period of time. It has a start time and a finish time. The finish time equals the start time plus the duration.
Subclass of Actioninterval
A position-related action class;
Jumpby,jumpto,moveby,moveto,bezierby,bezierto,cardinalsplineby,cardinalsplineto
The action class related to scaling;
Scaleto,scaleby,
The action class related to rotation;
Rotateby, Rotateto
Action classes related to tilt
Skewto,skewby
Action classes related to color changes
Fadeto,tintby,tintto
Action classes related to sequence actions
Sequence,spawn
Time-related action classes
Delaytime,repeat, Repeatforever,reversetime,actionfloat
Action classes related to progress
Progressfromto, Progressto
Action classes related to visibility
Blink
Action classes related to the grid
Gridaction
Action classes related to easing
Actionease
Animation-related action classes
Animate
Action classes related to 3D
Actioncamera,animate3d
Action classes with amplitude-related
Accelamplitude, Acceldeccelamplitude,deccelamplitude
Other related actions
Actiontween,targetedaction
Code section
API for the Jumpby,jumpto class
Static Jumpby * Create (float duration,//duration, in seconds.
Const VEC2 &position,//jumping distance.
Float height,//The height of the jump.
int jumps)//number of hops.
Static Jumpto * Create (float duration,//duration, in seconds.
Const VEC2 &position,//The location of the jumping destination.
Float height,//The height of the jump.
int jumps)//number of hops.
Instance:
Auto ACTIONTo = jumpto::create (2, VEC2 (300,300), 4); Auto Actionby = jumpby::create (2, VEC2 (300,0), 4);
API for the Moveby,moveto class
Static Moveby * Create (float duration,//duration, in seconds.
Const VEC2 &deltaposition)//displacement, VEC2 type.
Static Moveby * Create (float duration,//duration, in seconds.
Const VEC3 &deltaposition)//displacement, VEC3 type.
Static MoveTo * Create (float duration,//duration, in seconds.
Const VEC2 &position)//The target location of the two-dimensional world.
Static MoveTo * Create (float duration,//duration, in seconds.
Const VEC3 &position)//The target location of the three-dimensional world.
Instance:
Auto s = director::getinstance ()-getwinsize (); = Moveto::create (2, VEC2 (s.width-, s.height-)); = Moveby::create (2, VEC2 ());
API for the Bezierby,bezierto class
Static Bezierby * Create (float t,//duration, in seconds.
Const ccbezierconfig &C)//Bézier curve configuration.
Static Bezierto * Create (float t,//duration, in seconds.
Const ccbezierconfig &C)//Bézier curve configuration.
Instance:
//Sprite 1Ccbezierconfig Bézier; Bezier.controlpoint_1= VEC2 (0, s.height/2); Bezier.controlpoint_2= VEC2 ( -,-s.height/2); Bezier.endposition= VEC2 ( -, -); Auto Bezierforward= Bezierby::create (3, Bézier); Auto Bezierback= bezierforward->reverse (); Auto Rep=repeatforever::create (Sequence::create (Bezierforward, Bezierback, nullptr)); //Sprite 2_tamara->setposition ( the, the); Ccbezierconfig Bezier2; Bezier2.controlpoint_1= VEC2 ( -, s.height/2); Bezier2.controlpoint_2= VEC2 ( $,-s.height/2); Bezier2.endposition= VEC2 ( -, the); Auto BezierTo1= Bezierto::create (2, Bezier2);
API for the Cardinalsplineby,cardinalsplineto class
Static Cardinalsplineby * Create (float duration,//duration in seconds.
Pointarray *points,//Control Point Array.
Float tension)//curve tension.
Static Cardinalsplineto * Create (float duration,
Pointarray *points,//Control Point Array.
Float tension)//curve tension.
Instance:
Auto s = director::getinstance ()getwinsize (); Auto Array= Pointarray::create ( -); Array->addcontrolpoint (VEC2 (0,0)); Array->addcontrolpoint (VEC2 (s.width/2- -,0)); Array->addcontrolpoint (VEC2 (s.width/2- -, s.height- the)); Array->addcontrolpoint (VEC2 (0, s.height- the)); Array->addcontrolpoint (VEC2 (0,0)); Auto Action= Cardinalsplineby::create (3, Array,0);
Note, Cardinalsplineby,cardinalsplineto has sub-class successor Catmullromto,catmullromby, the difference is to set the default set tension 0.5, can not be changed.
API for the Scaleto,scaleby class
Static Scaleto * Create (float duration,//duration, in seconds.
float s)//x and y-axis scale.
Static Scaleto * Create (float duration,//duration, in seconds.
Float sx,//x axis scale.
Float sy)//y axis scale.
Static Scaleto * Create (float duration,//duration, in seconds.
Float sx,//x axis scale.
Float sy,//y axis scale.
float SZ)//z axis scale.
Instance:
Auto ACTIONTo = scaleto::create (2.0f0.5f); = Scaleby::create (2.0f1.0f10.0f);
Rotateby, API for Rotateto class
Static Rotateby * Create (float duration,//duration, in seconds.
float deltaangle)//rotation angle.
Static Rotateby * Create (float duration,//duration, in seconds.
float deltaanglez_x,//x axis rotation angle, measured in angle value.
float deltaanglez_y)//y axis rotation angle, measured in angle value.
Static Rotateby * Create (float duration,//duration, in seconds.
Const VEC3 &deltaangle3d)//three-dimensional rotation angle.
Static Rotateto * Create (float duration,//duration, in seconds.
The target angle of the float dstanglex,//x axis, measured in angle values.
float Dstangley) The target angle of the//y axis, measured in angle values.
Static Rotateto * Create (float duration,//duration, in seconds.
float dstangle)//target angle, measured in angle value.
Static Rotateto * Create (float duration,//duration, in seconds.
Const VEC3 &dstangle3d)//three-dimensional rotation angle.
Instance:
Auto ACTIONTo = rotateto::create (2); = Rotateto::create (200); = Rotateby::create (20.0f);
API for the Skewto,skewby class
Static SKEWTO * Create (float t,//duration, in seconds.
Float sx,//x axis target tilt angle.
Float sy)//y axis target tilt angle.
Static Skewby * Create (float t,//duration, in seconds.
Float deltaskewx,//x axis tilt angle.
float deltaskewy)//y axis tilt angle.
Instance:
Auto ACTIONTo = skewto::create (237.2f,-37.2f); = Skewto::create (200); = Skewby::create (20.0f,-90.0f);
Cocos Code Research (8) Continuous action sub-class learning notes