Cocos2d-x学习笔记3:九妹,图片拉伸按钮.

#include "cocos-ext.h"
using namespace cocos2d::extension;
void scale() {
    ui::Scale9Sprite *nineGirl = ui::Scale9Sprite::create("button.png");
    nineGirl->setContentSize(Size(200, 100));
    nineGirl->setPosition(Point(200, 200));
}

#include "cocos-ext.h"
using namespace cocos2d::extension;
void scale() {
    ui::Scale9Sprite *btnNormal = ui::Scale9Sprite::create("button.png");
//    nineGirl->setContentSize(Size(200, 100));
//    nineGirl->setPosition(Point(200, 200));
    ui::Scale9Sprite *btnDown = ui::Scale9Sprite::create("buttonHiglighted.png");
    //按钮标题
    Label *title = Label::create("007", "fonts/Marker Felt.ttf", 30);
    //创建按钮,按钮的大小会根据标题自动调整
    ControlButton *cBtn = ControlButton::create(title, btnNormal);
    //设置按钮按下时的图片
    cBtn->setBackgroundSpriteForState(btnDown, Control::State::HIGH_LIGHTED);
    
}

你可能感兴趣的:(Cocos2d-x学习笔记3:九妹,图片拉伸按钮.)