액션기능으로 이미지 이동하기



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 "test108.hpp"
 
USING_NS_CC;
 
Scene* Test108::createScene()
{
    auto scene = Scene::create();
    
    auto layer = Test108::create();
    scene->addChild(layer);
    
    return scene;
}
 
 
bool Test108::init()
{
    if ( !Layer::init())
    {
        return false;
    }
    
    
    auto sprite = Sprite::create("ball.png");
    sprite->setPosition(Point(50,50));
    this->addChild(sprite);
    
    
    //-By : 상대적인 값으로 변경, -To : 절대값으로 변경
    //MoveTo::create(이동시간, 이동할위치)
    auto action = MoveTo::create(3, Point(45050));
 
    //runAction(액션) : 객체에 액션지정
    sprite->runAction(action);
    
    return true;
}
 
cs



결과



+ Recent posts