cocos2dx九宫图使用方法

九宫格Sprite:

itemBg = Scale9Sprite::create("pop/achieve_itembg.png");
if(!itemBg)return false;
itemBg->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
itemBg->setContentSize(Size(548,100));//内容大小
itemBg->setCapInsets(Rect(20,20,2,2));//20 20 为原点坐标 2 2为不拉升区域的宽和高
this->addChild(itemBg,1);

 

 

按钮九宫格:

 Button* button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
 button->setScale9Enabled(true);
button->setCapInsets(Rect(5,5,15,15));

...

posted on 2015-02-28 17:07  益达的博客  阅读(809)  评论(0编辑  收藏  举报

导航