0、Sprite要执行动作,需要调用runAction,这个函数继承自Node类,参数是Action类指针。
FiniteTimeAction :有限时间动作
Follow :跟随动作
Speed :更改动作速度
2、FiniteTimeAction类有成员变量_duration记录动作的时间,
派生出三个子类:
ActionInstant :瞬时动作
ActionInterval :持续动作
ExtraAction :
3、ActionInstant瞬时动作就是一执行就结束了,_duration=0
常用的子类有:
FlipX/FlipY : 水平翻转/垂直翻转, FlipX::create(bool) 参数为true时表示翻转
Hide/Show/ToggleVisibility : 显示/隐藏/切换显示-隐藏状态,Hide::create()
Place : 设置位置,其实现是调用了setPosition Place::create(Vec2&)
RemoveSelf : 删除执行动作的对象。
CallFunc :调用函数。利用C++11 Lamda表达式,可以这样写
CallFunc::create([&]{ ... });
4、ActionInterval持续动作,在时间duration秒内完成动作。
MoveBy/MoveTo:移动一段距离/移动到某位置,MoveBy::create(float duration, const Vec2&)
ScaleTo/ScaleBy:缩放多少倍/缩放到多少倍,ScaleTo::create(float duration, float s)
SkewTo/SkewBy:翻转,SkewTo::create(float duration, float sx, float sy)
sx/sy表示以x轴/y轴翻转的角度。
TintTo/TintBy:改变颜色,TintTo::create(float duration, GLubyte red, GLubyte green, GLubyte blue)
r/g/b取值0~255
RotateTo/RotateBy:旋转,RotateTo::create(float duration, float dstAngleX, float dstAngleY)
参数为角度
JumpBy/JumpTo:跳跃,create(float duration, const Vec2& position, float height, int jumps)
FadeTo:改变透明度,FadeTo::create(float duration, GLubyte opacity)取值0~255
FadeIn/FadeOut:淡入/淡出,相当于FadeTo的参数为255/0,FadeIn::create(float duration)
Blink:闪烁,Blink::create(float duration, int blinks)一次闪烁就是执行对象显示/隐藏一次
BezierBy/BezierTo:贝赛尔曲线运动,BezierBy::create(float t, const ccBezierConfig& c)
typedef struct _ccBezierConfig {
Vec2 endPosition;
Vec2 controlPoint_1;
Vec2 controlPoint_2;
} ccBezierConfig;
Sequence:按先后顺序执行几个动作,
Sequence::create(FiniteTimeAction *action1, ...)参数以NULL结尾
Sequence::createWithTwoActions(FiniteTimeAction *actionOne, FiniteTimeAction *actionTwo)
Spawn:同时执行几个动作,
Spawn::create(FiniteTimeAction *action1, ...)参数以NULL结尾
Spawn::createWithTwoActions(FiniteTimeAction *actionOne, FiniteTimeAction *actionTwo)
Repeat:重复执行一个动作有限次数
Repeat::create(FiniteTimeAction *action, unsigned int times);
RepeatForever:无限次重复执行一个动作
RepeatForever::create(ActionInterval *action)
Animate:
ActionEase:
1、Action类,继承自Ref、Clonable。
派生出三个子类:FiniteTimeAction :有限时间动作
Follow :跟随动作
Speed :更改动作速度
2、FiniteTimeAction类有成员变量_duration记录动作的时间,
派生出三个子类:
ActionInstant :瞬时动作
ActionInterval :持续动作
ExtraAction :
3、ActionInstant瞬时动作就是一执行就结束了,_duration=0
常用的子类有:
FlipX/FlipY : 水平翻转/垂直翻转, FlipX::create(bool) 参数为true时表示翻转
Hide/Show/ToggleVisibility : 显示/隐藏/切换显示-隐藏状态,Hide::create()
Place : 设置位置,其实现是调用了setPosition Place::create(Vec2&)
RemoveSelf : 删除执行动作的对象。
CallFunc :调用函数。利用C++11 Lamda表达式,可以这样写
CallFunc::create([&]{ ... });
4、ActionInterval持续动作,在时间duration秒内完成动作。
MoveBy/MoveTo:移动一段距离/移动到某位置,MoveBy::create(float duration, const Vec2&)
ScaleTo/ScaleBy:缩放多少倍/缩放到多少倍,ScaleTo::create(float duration, float s)
SkewTo/SkewBy:翻转,SkewTo::create(float duration, float sx, float sy)
sx/sy表示以x轴/y轴翻转的角度。
TintTo/TintBy:改变颜色,TintTo::create(float duration, GLubyte red, GLubyte green, GLubyte blue)
r/g/b取值0~255
RotateTo/RotateBy:旋转,RotateTo::create(float duration, float dstAngleX, float dstAngleY)
参数为角度
JumpBy/JumpTo:跳跃,create(float duration, const Vec2& position, float height, int jumps)
FadeTo:改变透明度,FadeTo::create(float duration, GLubyte opacity)取值0~255
FadeIn/FadeOut:淡入/淡出,相当于FadeTo的参数为255/0,FadeIn::create(float duration)
Blink:闪烁,Blink::create(float duration, int blinks)一次闪烁就是执行对象显示/隐藏一次
BezierBy/BezierTo:贝赛尔曲线运动,BezierBy::create(float t, const ccBezierConfig& c)
typedef struct _ccBezierConfig {
Vec2 endPosition;
Vec2 controlPoint_1;
Vec2 controlPoint_2;
} ccBezierConfig;
Sequence:按先后顺序执行几个动作,
Sequence::create(FiniteTimeAction *action1, ...)参数以NULL结尾
Sequence::createWithTwoActions(FiniteTimeAction *actionOne, FiniteTimeAction *actionTwo)
Spawn:同时执行几个动作,
Spawn::create(FiniteTimeAction *action1, ...)参数以NULL结尾
Spawn::createWithTwoActions(FiniteTimeAction *actionOne, FiniteTimeAction *actionTwo)
Repeat:重复执行一个动作有限次数
Repeat::create(FiniteTimeAction *action, unsigned int times);
RepeatForever:无限次重复执行一个动作
RepeatForever::create(ActionInterval *action)
Animate:
ActionEase: