참고 : http://injakaun.tistory.com/96


1. Sequence

시퀀스는 2개 이상의 액션들을 조합해서 순차적으로 실행하게 해주는 액션입니다. 


Sequence

MoveTo *action_0 = MoveTo::create(1.0f, Point(200, 200));
MoveTo *action_1 = MoveTo::create(1.0f, Point(150, 150));
Sequence *action_2 = Sequence::create(action_0, action_1, NULL);


2. Spawn

이 액션은 동시에 여러개의 액션을 실행시키는 액션입니다.


Spawn

MoveTo *action_0 = MoveTo::create(1.0f, Point(200, 200));
FadeTo *action_1 = FadeTo::create(2.0f, 128);

Spawn *action_2 = Spawn::create(action_0, action_1, NULL);


3. Reverse

리버스는 실행했던 액션을 반대로 실행시켜주는 기능입니다.

단, 반대로 실행할 수 있는 기능들만 실행됩니다.


MoveBy *action_0 = MoveBy::create(1.0f, Point(200, 200));

MoveBy *action_1 = action_0->reverse();

Sequence *action_2 = Sequence::create(action_0, action_1, NULL);


4. DelayTime

딜레이타임은 지정된 시간만큼 기다리는 액션입니다.

보통 2개 이상의 조합액션을 할 때 많이 사용됩니다.


CCDelayTime

MoveTo *action_0 = MoveTo::create(1.0f, Point(200, 200));
DelayTime *action_1 = DelayTime::create(3.0f);    // 시간
MoveTo *action_2 = MoveTo::create(1.0f, Point(150, 150));
Sequence *action_3 = Sequence::create(action_0, action_1, action_2, NULL);


5. Repeat, RepeatForever

이 액션은 지정된 액션을 지정한 횟수만큼 반복하는 액션입니다.


Repeat

MoveTo *action_0 = MoveTo::create(1.0f, Point(200, 200));

MoveTo *action_1 = MoveTo::create(1.0f, Point(150, 150));
Sequence *action_2 = Sequence::create(action_0, action_1, NULL);
Repeat *action_3 = Repeat::create(action_2, 10);    // 액션 , 횟수


횟수를 지정하지 않고 무한반복을 할 때에는 아래 액션을 사용하면 됩니다.


RepeatForever

MoveTo *action_0 = MoveTo::create(1.0f, Point(200, 200));

MoveTo *action_1 = MoveTo::create(1.0f, Point(150, 150));
Sequence *action_2 = Sequence::create(action_0, action_1, NULL);

RepeatForever *action_3 = RepeatForever::create(action_2);


6. Ease Action

이지액션은 어떠한 액션을 실행할때 등속이 아닌 특정한 가속도를 주어서 실행하게 해주는 액션입니다.

여기서 In은 가속부분에서 천천히 되는 부분이 앞에 있는 것을 말하며, Out는 천천히 되는 부분이 뒤에 있는 것을 말합니다. InOut는 앞뒤에 부분이 천천히 가속되는 것을 말합니다.


EaseIn, EaseOut, EaseInOut

가속의 범위를 탄성이라는 값으로 지정할 수 있는 액션입니다.


MoveTo *action_0 = MoveTo::create(3.0f, Point(300, 300));

EaseInOut *action_1 = EaseInOut::create(action_0, 3.0);    // action, 탄성


EaseExponentialIn, EaseExponentialOut, EaseExponentialInOut

가속의 차가 많이 나는 액션입니다.


MoveTo *action_0 = MoveTo::create(3.0f, Point(300, 300));

EaseExponentialIn *action_1 = EaseExponentialIn::create(action_0);


EaseSineIn, EaseSineOut, EaseSineInOut

가속의 차가 조금 나는 액션입니다.


MoveTo *action_0 = MoveTo::create(3.0f, Point(300, 300));

EaseSineIn *action_1 = EaseSineIn::create(action_0);


EaseElasticIn, EaseElasticOut, EaseElasticInOut

고무줄에 튕기는 듯한 느낌을 주는 액션입니다.


MoveTo *action_0 = MoveTo::create(3.0f, Point(300, 300));

EaseElasticIn *action_1 = EaseElasticIn::create(action_0);


EaseBounceIn, EaseBounceOut, EaseBounceInOut

공이 튀기는 듯한 느낌을 주는 액션입니다.


MoveTo *action_0 = MoveTo::create(3.0f, Point(300, 300));

EaseBounceIn *action_1 = EaseBounceIn::create(action_0);


EaseBackIn, EaseBackOut, EaseBackInOut

뒤로 갔다가 다시 앞으로 오는 액션입니다.


MoveTo *action_0 = MoveTo::create(3.0f, Point(300, 300));

EaseBackIn *action_1 = EaseBackIn::create(action_0);


7. Call Function

이 액션은 메소드를 호출하는 액션입니다.

메소드를 호출하면서 어떠한 값을 넘겨주느냐에 따라서 4종류의 액션으로 구분됩니다.


CallFunc

아무런 값을 넘겨주지 않고 메소드만 호출하는 액션입니다.


MoveTo *action_0 = MoveTo::create(1.0f, Point(200, 200));
CallFunc *action_1 = CallFunc::create(CC_CALLBACK_0(HelloWorld::goCall, this));
Sequence *action_2 = Sequence::create(action_0, action_1, NULL);


void HelloWorld::goCall() {

    CCLOG(__FUNCTION__);

}


CallFuncN

메소드를 호출하면서 액션을 실행하는 주체를 넘겨주는 액션입니다.

넘겨준 주체는 호출되는 메소드에서 아래와 같이 사용할 수 있습니다.


MoveTo *action_0 = MoveTo::create(1.0f, Point(200, 200));

CallFuncN *action_1 = CallFuncN::create(CC_CALLBACK_1(HelloWorld::goCall, this))
Sequence *action_2 = Sequence::actions(action_0, action_1, NULL);

spr->runAction(action_2);


void HelloWorld::goCall(Node *pSender) {

    Sprite *spr = (Sprite *)pSender;

    spr->setScale(2);

}


CallFuncN

메소드를 호출하면서 주체 및 특정한 값을 넘겨주는 액션입니다.


MoveTo *action_0 = MoveTo::create(1.0f, Point(200, 200));

CallFuncN *action_1 = CallFuncN::create(CC_CALLBACK_1(HelloWorld::goCall, this, (void*)"cocos2d-x"));
Sequence *action_2 = Sequence::create(action_0, action_1, NULL);

spr->runAction(action_2);


void HelloWorld::goCall(Node *pSender, void *d) {

    CCLOG("goCall %s", (char*)d);

    Sprite *spr = (Sprite *)pSender;

    spr->setScale(2);

}


CCCallFuncN

이 액션은 메소드를 호출하면서 액션을 실행하는 주체가 아닌 다른 오브젝트를 넘겨주는 액션입니다.


MoveTo *action_0 = MoveTo::create(1.0f, Point(200, 200));

CallFuncN *action_1 = CallFuncN::create(CC_CALLBACK_1(HelloWorld::goCall, this, spr_2));
Sequence *action_2 = Sequence::create(action_0, action_1, NULL);

spr_1->runAction(action_2);


void HelloWorld::goCall(Node *pSender, Object *o) {

    Sprite *spr = (Sprite *)o;

    spr->setScale(2);

}

+ Recent posts