博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Cocos2d-x Layout简单使用
阅读量:4537 次
发布时间:2019-06-08

本文共 1948 字,大约阅读时间需要 6 分钟。

1、

Text* alert = Text::create("Layout", "fonts/Marker Felt.ttf", 30 );        alert->setColor(Color3B(159, 168, 176));        alert->setPosition(Point(widgetSize.width / 2.0f,                                 widgetSize.height / 2.0f - alert->getSize().height * 3.075f));                addChild(alert);                        Layout* layout = Layout::create();        layout->setSize(Size(280, 150));        layout->setBackGroundColorType(LAYOUT_COLOR_SOLID);        layout->setBackGroundColor(Color3B::RED);        layout->setPosition(Point(widgetSize.width / 2,widgetSize.height / 2));        addChild(layout);                Button* button = Button::create("animationbuttonnormal.png", "animationbuttonpressed.png");        button->setPosition(Point(button->getSize().width / 2.0f,                                  layout->getSize().height - button->getSize().height / 2.0f));        layout->addChild(button);                        Button* titleButton = Button::create("backtotopnormal.png","backtotoppressed.png");        titleButton->setTitleText("Title Button");        titleButton->setScale9Enabled(true);        titleButton->setSize(Size(100, 100));        titleButton->setTitleFontSize(20);                        titleButton->setPosition(Point(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));        layout->addChild(titleButton);

/*渐变色*/        layout->setBackGroundColorType(LAYOUT_COLOR_GRADIENT);        layout->setBackGroundColor(Color3B::RED, Color3B(192, 192, 192));
/*单色*/        layout->setBackGroundColorType(LAYOUT_COLOR_SOLID);        layout->setBackGroundColor(Color3B::RED);

/*以图片为背景*/        layout->setBackGroundImageScale9Enabled(true);        layout->setBackGroundImage("green_edit.png");
//纵向排列,这里相似Android里的线性布局         layout->setLayoutType(LAYOUT_LINEAR_VERTICAL);
//横向排列,这里相似Android里的线性布局         layout->setLayoutType(LAYOUT_LINEAR_HORIZONTAL);

转载于:https://www.cnblogs.com/mfrbuaa/p/5064598.html

你可能感兴趣的文章
ASP.NET导出Excel,打开时提示“您尝试打开文件'XXX.xls'的格式与文件扩展名指定文件不一致”...
查看>>
Javaweb之 servlet 开发详解1
查看>>
Restore IP Addresses
查看>>
DWR框架简单应用
查看>>
KMP 学习心得-----转
查看>>
time.strftime:格式化字符串中含中文报错处理
查看>>
模态窗口缓存无法清除怎么办? 在地址上加个随机数吧"&rd=" + new Date().getTime()
查看>>
阿里的weex框架到底是什么
查看>>
Tesis enDYNA
查看>>
FxZ,C#开发职位面试测试题(30分钟内必须完成)
查看>>
[HNOI2007]分裂游戏
查看>>
Pandas基本介绍
查看>>
当拖动滚动条时 出现小图标
查看>>
LeetCode "Shortest Word Distance II"
查看>>
绕过阿里云防火墙继续扫描探测和SQL注入
查看>>
ln 软链接与硬链接
查看>>
JQuery ajax请求一直返回Error(parsererror)
查看>>
利用POI 技术动态替换word模板内容
查看>>
LeetCode No.168
查看>>
纪录jmeter loop controller 使用中的一个坑
查看>>