반대로 실행하는 액션기능 (reverse)



c++)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "test131.hpp"
 
USING_NS_CC;
 
Scene* Test131::createScene()
{
    auto scene = Scene::create();
    
    auto layer = Test131::create();
    scene->addChild(layer);
    
    return scene;
}
 
 
bool Test131::init()
{
    if ( !Layer::init())
    {
        return false;
    }
    
    
    auto sprite = Sprite::create("ball.png");
    sprite->setPosition(Point(100,100));
    this->addChild(sprite);
    
    
    auto action1 = MoveBy::create(2.0, Point(300,100));
    //reverse() : 실행했던 액션을 반대로 실행시키는액션
    //ps. 반대로 실행할 수 있는 액션인 상대적인 위치를 나타내는 ~By로 끝나는 액션을 적용해야 한다
    auto reverseAction = action1->reverse();
    auto requenceAction = Sequence::create(action1, reverseAction, NULL);
    sprite->runAction(requenceAction);
    
    
    return true;
}
 
cs



결과

객체가 (400,200)으로 이동했다가 (100,100)으로 다시 이동한다



+ Recent posts