九宫格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));
...
时间: 2024-10-14 23:33:14