#include "Action_2.h"
Action_2::Action_2()
{
}
Action_2::~Action_2()
{
}
CCScene *Action_2::scene()
{
CCSize size = CCDirector::sharedDirector()->getWinSize();
Action_2 *layer = Action_2::create();
CCScene *scene = CCScene::create();
scene->addChild(layer);
return scene;
}
bool Action_2::init()
{
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCSprite *sp1 = CCSprite::create("20160222150945.png");
sp1->setPosition(ccp(size.width*0.1, size.height*0.1));
addChild(sp1);
//移动
//CCActionInterval *move = CCMoveTo::create(3.3f, ccp(size.width*0.9, size.height*0.9));
//sp1->runAction(move);
//sp1->runAction(CCMoveTo::create(3.3f, ccp(size.width*0.9, size.height*0.9)));
//跳跃
CCActionInterval *jump = CCJumpTo::create(10.0f, ccp(size.width*0.1, size.height*0.1), 120.0f, 4);
//sp1->runAction(jump);
//放大 缩小第一个参数小于0
//sp1->runAction(CCScaleTo::create(1.0f,2.0f));
//旋转
//sp1->runAction(CCRotateTo::create(1.0f, 2.0f));
//倾斜
//sp1->runAction(CCSkewTo::create(2.0f, 20.0f,20.0));
//闪烁
//sp1->runAction(CCBlink::create(2.0, 19));
//淡入
//sp1->runAction(CCFadeIn::create(30.f));
//淡出
//sp1->runAction(CCFadeOut::create(30.f));
//
//sp1->runAction(CCFadeIn::create(3.f));
//颜色渐变
//sp1->runAction(CCTintTo::create(3.f,255,121,100));
//线条曲线
CCPointArray *arr = CCPointArray::create(10);
arr->addControlPoint(ccp(size.width*0.2, size.height*0.2));
arr->addControlPoint(ccp(size.width*0.2, size.height*0.8));
arr->addControlPoint(ccp(size.width*0.8, size.height*0.8));
arr->addControlPoint(ccp(size.width*0.8, size.height*0.2));
arr->addControlPoint(ccp(size.width*0.2, size.height*0.2));
CCActionInterval *spline = CCCardinalSplineTo::create(5.0f, arr, 3.0f);
//sp1->runAction(spline);
//顺序执行
//CCActionInterval *seq = CCSequence::create(spline, jump, NULL);
//sp1->runAction(seq);
//同时执行
//CCActionInterval *sae = CCSpawn::create(spline, jump, NULL);
//sp1->runAction(sae);
//CCdelaytime
CCActionInterval *seq = CCSequence::create(spline, CCDelayTime::create(2.1f),jump, NULL);
//sp1->runAction(seq);
//重复五次
sp1->runAction(CCRepeat::create(seq, 5));
//永久重复
//sp1->runAction(CCRepeatForever::create(seq));
return true;
}
void callback()
{
}