뒤로 이동하는 이즈액션



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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "test143.hpp"
 
USING_NS_CC;
 
Scene* Test143::createScene()
{
    auto scene = Scene::create();
    
    auto layer = Test143::create();
    scene->addChild(layer);
    
    return scene;
}
 
 
bool Test143::init()
{
    if ( !Layer::init())
    {
        return false;
    }
    
    
    auto sprite1 = Sprite::create("ball.png");
    sprite1->setPosition(Point(100,90));
    this->addChild(sprite1);
    
    auto sprite2 = Sprite::create("ball.png");
    sprite2->setPosition(Point(100,70));
    this->addChild(sprite2);
    
    auto sprite3 = Sprite::create("ball.png");
    sprite3->setPosition(Point(100,50));
    this->addChild(sprite3);
    
    
    //EaseBack 이즈액션 : 뒤로 이동했다가 도착점으로 이동하는 이즈액션
    //EaseBackIn : 시작점에서 뒤로 이동했다가 도착점으로 이동
    //EaseBackOut : 도착점보다 더 이동했다가 도착점으로 돌아옴
    //EaseBackInOut : 시작점에서도 뒤로 이동하고 도착점에서도 더 이동했다가 도착점으로 돌아옴
    auto action1 = MoveTo::create(2.0, Point(450,90));
    auto ease1 = EaseBackIn::create(action1);
    
    auto action2 = MoveTo::create(2.0, Point(450,70));
    auto ease2 = EaseBackOut::create(action2);
    
    auto action3 = MoveTo::create(2.0, Point(450,50));
    auto ease3 = EaseBackInOut::create(action3);
    
    
    //스프라이트 객체에 액션을 실행
    sprite1->runAction(ease1);
    sprite2->runAction(ease2);
    sprite3->runAction(ease3);
    
    
    return true;
}
 
cs



결과

각기 다른 가속도로 뒤로 이동하게 된다



+ Recent posts