액션기능으로 점프하기 (JumpBy)



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
#include "test111.hpp"
 
USING_NS_CC;
 
Scene* Test111::createScene()
{
    auto scene = Scene::create();
    
    auto layer = Test111::create();
    scene->addChild(layer);
    
    return scene;
}
 
 
bool Test111::init()
{
    if ( !Layer::init())
    {
        return false;
    }
    
    
    auto sprite = Sprite::create("ball.png");   //스프라이트 이미지 객체
    sprite->setPosition(Point(100,100));    //이미지 위치 지정
    this->addChild(sprite); //레이어에 추가
    
    
    //JumpBy JumpTo : 지정한 위치로 객체의 위치를 변경해주면서 지정한 높이로 지정한 횟수만큼 점프하는 액션
    //액션은 Node를 상속받은 객체(Layer , Sprite , Label)에 실행
    //JumpBy::create(지속시간 , 위치 , 점프높이 , 점프횟수);
    auto action = JumpBy::create(5.0f, Point(300,0), 1504);
    sprite->runAction(action);
    
        
    return true;
}
 
cs






+ Recent posts