2014년 7월 21일 월요일

cocos2d-x 9patch 이미지.

안드로이드처럼 cocos2d도 9patch가 가능하다.

#include "GUI/CCControlExtension/CCControlExtensions.h"
...
using namespace cocos2d::extension;
...

1
2
3
4
5
6
   auto sprite9patch = Scale9Sprite::create(Rect(55, 115, 157, 97),  "TEST/btn9Patch/red.png");
    auto winSize = DK_GET_WINSIZE;
    sprite9patch->setContentSize(Size(winSize.width / 10 * 9,
                                      winSize.height / 10 * 9));
    sprite9patch->setPosition(winSize.width/2, winSize.height/2);
    addChild(sprite9patch);


위와 같이 Scale9Sprite를 쓰면된다.

생성 팩토리 함수의 매개변수는
첫번째 인자로 늘릴 범위의 Rect를 전달하고,
두번째 인자는 늘릴 이미지의 경로를 전달하면 된다.

단순.


댓글 없음:

댓글 쓰기

리스트