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);
    
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容