3차 베지어곡선은 아직 이해하진 못하겠다.

사용법은 아래와 같음.

BezierBy : 상대적 거리

BezierTo : 좌표


bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }

    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

    mySprite = Sprite::create("CloseNormal.png");
    mySprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
    this->addChild(mySprite);
    
    //추가할 내용
	ccBezierConfig bezier;
	bezier.controlPoint_1 = Vec2(0, visibleSize.height / 2);
	bezier.controlPoint_2 = Vec2(300, -visibleSize.height / 2);
	bezier.endPosition = Vec2(200, 100);

	auto action = BezierBy::create(3, bezier);
	mySprite->runAction(action);

    return true;
}


'Cocos2D-X' 카테고리의 다른 글

스케일(ScaleBy, ScaleTo)  (0) 2016.05.09
어떤 지점에 놓음(Place)  (0) 2016.05.09
점프 시뮬레이션(JumpBy, JumpTo)  (0) 2016.05.08
스프라이트 이동(MoveBy, MoveTo)  (0) 2016.05.07
스프라이트추가(Sprite)  (0) 2016.05.07
Posted by 빵원군
,

생성한 스프라이트 점프 시뮬레이션(2번째 인자는 거리)

JumpTo의 경우 2번째 인자가 최종 목표좌표

HelloWorldScene.cpp

bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }

    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

    mySprite = Sprite::create("CloseNormal.png");
    mySprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
    this->addChild(mySprite);
    
    //추가할 내용
    auto action = JumpBy::create(3, Vec2(100, 50), 50, 3);
    mySprite->runAction(action);

    return true;
}


'Cocos2D-X' 카테고리의 다른 글

어떤 지점에 놓음(Place)  (0) 2016.05.09
3차 베지어곡선(BezierBy, BezierTo)  (0) 2016.05.08
스프라이트 이동(MoveBy, MoveTo)  (0) 2016.05.07
스프라이트추가(Sprite)  (0) 2016.05.07
NDK설치시  (0) 2016.05.07
Posted by 빵원군
,

생성한 스프라이트를 특정 벡터만큼 이동(상대적 좌표)

MoveTo의 경우 절대좌표


HelloWorldScene.cpp
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }

    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

    mySprite = Sprite::create("CloseNormal.png");
    mySprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
    this->addChild(mySprite);
    
    //추가할 내용
    auto action = MoveBy::create(3, Vec2(50, 150));
    mySprite->runAction(action);

    return true;
}


'Cocos2D-X' 카테고리의 다른 글

어떤 지점에 놓음(Place)  (0) 2016.05.09
3차 베지어곡선(BezierBy, BezierTo)  (0) 2016.05.08
점프 시뮬레이션(JumpBy, JumpTo)  (0) 2016.05.08
스프라이트추가(Sprite)  (0) 2016.05.07
NDK설치시  (0) 2016.05.07
Posted by 빵원군
,