cocos2d-x引擎中,动作(Action)定义了在节点上的通用操作,他不依赖于节点,但是
在运行时需要指定节点为目标,动作最直观的好处就是可以实现很多动画效果,如精灵的行走、
跳跃等
CCAction是所有动作的基类:
CCSpeed:调整实体(节点)的执行速度;CCFollow:可以使节点跟随指定的另一个节点移动
瞬时动作(CCActionInstant)与延时动作(CCActionInterval):
瞬时动作的主要特点就是不需要花费时间,瞬间就能完成动作的执行,这些动作的基类为CCActionInstant
延时动作的主要特点就是执行动作需要花费一定的时间,这些动作的基类为CCActionInterval
CCMoveTo和CCMoveBy的区别
移动精灵,两者的区别在于:CCMoveTo是移动到指定坐标,CCMoveBy是相对坐标。
如ccp(80,80),前者表示移动到x=80,y=80处,后者表示向x方向移动80个单位,向y方向移动80个单位。
void ActionsDemo::onEnter() //场景加载时的回调函数
{
CCLayer::onEnter();
// Or you can create an sprite using a filename. only PNG is supported now. Probably TIFF too
m_grossini = CCSprite::create(s_pPathGrossini);
m_grossini->retain();
m_tamara = CCSprite::create(s_pPathSister1);
m_tamara->retain();
m_kathia = CCSprite::create(s_pPathSister2);
m_kathia->retain();
addChild(m_grossini, 1);
addChild(m_tamara, 2);
addChild(m_kathi