가속도를 주어서 실행하는 이즈액션



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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "test135.hpp"
 
USING_NS_CC;
 
Scene* Test135::createScene()
{
    auto scene = Scene::create();
    
    auto layer = Test135::create();
    scene->addChild(layer);
    
    return scene;
}
 
 
bool Test135::init()
{
    if ( !Layer::init())
    {
        return false;
    }
    
    
    auto sprite1 = Sprite::create("ball.png");
    sprite1->setPosition(Point(100,30));
    this->addChild(sprite1);
    auto sprite2 = Sprite::create("ball.png");
    sprite2->setPosition(Point(100,40));
    this->addChild(sprite2);
    auto sprite3 = Sprite::create("ball.png");
    sprite3->setPosition(Point(100,50));
    this->addChild(sprite3);
    auto sprite4 = Sprite::create("ball.png");
    sprite4->setPosition(Point(100,60));
    this->addChild(sprite4);
    auto sprite5 = Sprite::create("ball.png");
    sprite5->setPosition(Point(100,70));
    this->addChild(sprite5);
    auto sprite6 = Sprite::create("ball.png");
    sprite6->setPosition(Point(100,80));
    this->addChild(sprite6);
 
    
    
    auto action1 = MoveTo::create(2.0, Point(400,30));
    auto action2 = MoveTo::create(2.0, Point(400,40));
    auto action3 = MoveTo::create(2.0, Point(400,50));
    auto action4 = MoveTo::create(2.0, Point(400,60));
    auto action5 = MoveTo::create(2.0, Point(400,70));
    auto action6 = MoveTo::create(2.0, Point(400,80));
    //이즈 액션 : 동일한 속도가 아닌 특정한 가속도를 주어서 실행하게 해주는 액션
    //ps. 가속도비율이 1이면 등속도운동을 하고 비율값이 클수록 느린부분과 빠른부분의 차이가 많이난다
    
    //EaseIn::create(액션, 가속도비율) : 앞부분을 느리게
    //EaseOut : 뒷부분을 느리게
    //EaseInOut : 앞부분과 뒷부분을 느리게
    auto easeIn = EaseIn::create(action1, 3.0);
    auto easeOut = EaseOut::create(action2, 3.0);
    auto easeInOut = EaseInOut::create(action3, 3.0);
    
    //EaseSine : 가속비율이 작은 액션 <-> EaseExponential : 가속비율이 큰 액션
    //EaseSineIn::create(액션) , EaseExponentialIn : 앞부분을 느리게
    //EaseSineOut , EaseExponentialOut : 뒷부분을 느리게
    //EaseSineInOut , EaseExponentialInOut : 앞부분과 뒷부분을 느리게
    auto easeSineIn = EaseSineIn::create(action4);
    auto easeSineOut = EaseSineIn::create(action5);
    auto easeSineInOut = EaseSineIn::create(action6);
 
    sprite1->runAction(easeIn);
    sprite2->runAction(easeOut);
    sprite3->runAction(easeInOut);
    sprite4->runAction(easeSineIn);
    sprite5->runAction(easeSineOut);
    sprite6->runAction(easeSineInOut);
    
    
    return true;
}
 
cs



결과

이즈액션 종류마다 각각 다른 가속도를 주어 실행된다



+ Recent posts