크기 변경하는 액션기능 (ScaleTo)



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
#include "test116.hpp"
 
USING_NS_CC;
 
Scene* Test116::createScene()
{
    auto scene = Scene::create();
    
    auto layer = Test116::create();
    scene->addChild(layer);
    
    return scene;
}
 
 
bool Test116::init()
{
    if ( !Layer::init())
    {
        return false;
    }
    
    
    auto sprite = Sprite::create("ball.png");   //스프라이트 이미지 객체 생성
    sprite->setPosition(Point(100,100));    //스프라이트 위치 지정
    sprite->setScale(2);    //크기지정(2배 확대)
    this->addChild(sprite); //레이어에 추가
    
    
    //ScaleTo::create(액션시간, 크기)
    //ScaleBy : 현재크기 기준(8배 확대), ScaleTo : 지정한크기 기준(3배 확대)
    auto action = ScaleBy::create(23);
    sprite->runAction(action);
    
    
    
    
    return true;
}
 
cs



결과

이미지가 8배로 확대된다



+ Recent posts