고무줄에서 튕기는 것처럼 실행하는 이즈액션



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 "test141.hpp"
 
USING_NS_CC;
 
Scene* Test141::createScene()
{
    auto scene = Scene::create();
    
    auto layer = Test141::create();
    scene->addChild(layer);
    
    return scene;
}
 
 
bool Test141::init()
{
    if ( !Layer::init())
    {
        return false;
    }
    
 
    auto sprite1 = Sprite::create("ball.png");
    sprite1->setPosition(Point(100,50));
    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,90));
    this->addChild(sprite3);
 
    
    //EaseElastic 이즈 액션 : 고물줄처럼 튕기는 효과를 주는 액션
    //EaseElasticIn : 시작점에서 고무줄에서 튕기는 것처럼 앞뒤로 움직인다
    //EaseElasticOut : 도착점에서 고무줄에서 튕기는 것처럼 앞뒤로 움직인다
    //EaseElasticInOut : 시작점, 도착점에서 고무줄에서 튕기는 것처럼 앞뒤로 움직인다
    auto action1 = MoveTo::create(2.0, Point(400,50));
    auto ease1 = EaseElasticIn::create(action1);
    
    auto action2 = MoveTo::create(2.0, Point(400,70));
    auto ease2 = EaseElasticOut::create(action2);
    
    auto action3 = MoveTo::create(2.0, Point(400,90));
    auto ease3 = EaseElasticInOut::create(action3);
    
    
    //스프라이트 객체에 액션적용
    sprite1->runAction(ease1);
    sprite2->runAction(ease2);
    sprite3->runAction(ease3);
    
    
    return true;
}
 
cs



결과

각각 다른 가속도록 고무줄처럼 튕긴다



+ Recent posts