Cocos2d-x Layout使用三
来源:互联网 发布:贫女如花之镜知 编辑:程序博客网 时间:2024/05/02 02:19
Layout* layout = Layout::create();
layout->setLayoutType(LayoutType::RELATIVE);
layout->setContentSize(Size(600, 550));
layout->setAnchorPoint(Point(0.5f,0.5f));
layout->setBackGroundColorType(Layout::BackGroundColorType::SOLID);
layout->setBackGroundColor(Color3B::GREEN);
Size size = Director::getInstance()->getVisibleSize();
layout->setPosition(Vec2(size.width / 2.0f ,size.height / 2));
this->addChild(layout);
// top left
Button* button_TopLeft = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");
layout->addChild(button_TopLeft);
RelativeLayoutParameter* rp_TopLeft = RelativeLayoutParameter::create();
rp_TopLeft->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_TOP_LEFT);
button_TopLeft->setLayoutParameter(rp_TopLeft);
// top center horizontal
Button* button_TopCenter = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");
layout->addChild(button_TopCenter);
RelativeLayoutParameter* rp_TopCenter = RelativeLayoutParameter::create();
rp_TopCenter->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_TOP_CENTER_HORIZONTAL);
button_TopCenter->setLayoutParameter(rp_TopCenter);
// top right
Button* button_TopRight = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");
layout->addChild(button_TopRight);
RelativeLayoutParameter* rp_TopRight = RelativeLayoutParameter::create();
rp_TopRight->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_TOP_RIGHT);
button_TopRight->setLayoutParameter(rp_TopRight);
// left center
Button* button_LeftCenter = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");
layout->addChild(button_LeftCenter);
RelativeLayoutParameter* rp_LeftCenter = RelativeLayoutParameter::create();
rp_LeftCenter->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_CENTER_VERTICAL);
button_LeftCenter->setLayoutParameter(rp_LeftCenter);
// center
Button* buttonCenter = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");
layout->addChild(buttonCenter);
RelativeLayoutParameter* rpCenter = RelativeLayoutParameter::create();
rpCenter->setAlign(RelativeLayoutParameter::RelativeAlign::CENTER_IN_PARENT);
buttonCenter->setLayoutParameter(rpCenter);
// right center
Button* button_RightCenter = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");
layout->addChild(button_RightCenter);
RelativeLayoutParameter* rp_RightCenter = RelativeLayoutParameter::create();
rp_RightCenter->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_CENTER_VERTICAL);
button_RightCenter->setLayoutParameter(rp_RightCenter);
// left bottom
Button* button_LeftBottom = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");
layout->addChild(button_LeftBottom);
RelativeLayoutParameter* rp_LeftBottom = RelativeLayoutParameter::create();
rp_LeftBottom->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_BOTTOM);
button_LeftBottom->setLayoutParameter(rp_LeftBottom);
// bottom center
Button* button_BottomCenter = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");
layout->addChild(button_BottomCenter);
RelativeLayoutParameter* rp_BottomCenter = RelativeLayoutParameter::create();
rp_BottomCenter->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_BOTTOM_CENTER_HORIZONTAL);
button_BottomCenter->setLayoutParameter(rp_BottomCenter);
// right bottom
Button* button_RightBottom = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");
layout->addChild(button_RightBottom);
RelativeLayoutParameter* rp_RightBottom = RelativeLayoutParameter::create();
rp_RightBottom->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_BOTTOM);
button_RightBottom->setLayoutParameter(rp_RightBottom);
layout->setLayoutType(LayoutType::RELATIVE);
layout->setContentSize(Size(600, 550));
layout->setAnchorPoint(Point(0.5f,0.5f));
layout->setBackGroundColorType(Layout::BackGroundColorType::SOLID);
layout->setBackGroundColor(Color3B::GREEN);
Size size = Director::getInstance()->getVisibleSize();
layout->setPosition(Vec2(size.width / 2.0f ,size.height / 2));
this->addChild(layout);
// top left
Button* button_TopLeft = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");
layout->addChild(button_TopLeft);
RelativeLayoutParameter* rp_TopLeft = RelativeLayoutParameter::create();
rp_TopLeft->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_TOP_LEFT);
button_TopLeft->setLayoutParameter(rp_TopLeft);
// top center horizontal
Button* button_TopCenter = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");
layout->addChild(button_TopCenter);
RelativeLayoutParameter* rp_TopCenter = RelativeLayoutParameter::create();
rp_TopCenter->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_TOP_CENTER_HORIZONTAL);
button_TopCenter->setLayoutParameter(rp_TopCenter);
// top right
Button* button_TopRight = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");
layout->addChild(button_TopRight);
RelativeLayoutParameter* rp_TopRight = RelativeLayoutParameter::create();
rp_TopRight->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_TOP_RIGHT);
button_TopRight->setLayoutParameter(rp_TopRight);
// left center
Button* button_LeftCenter = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");
layout->addChild(button_LeftCenter);
RelativeLayoutParameter* rp_LeftCenter = RelativeLayoutParameter::create();
rp_LeftCenter->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_CENTER_VERTICAL);
button_LeftCenter->setLayoutParameter(rp_LeftCenter);
// center
Button* buttonCenter = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");
layout->addChild(buttonCenter);
RelativeLayoutParameter* rpCenter = RelativeLayoutParameter::create();
rpCenter->setAlign(RelativeLayoutParameter::RelativeAlign::CENTER_IN_PARENT);
buttonCenter->setLayoutParameter(rpCenter);
// right center
Button* button_RightCenter = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");
layout->addChild(button_RightCenter);
RelativeLayoutParameter* rp_RightCenter = RelativeLayoutParameter::create();
rp_RightCenter->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_CENTER_VERTICAL);
button_RightCenter->setLayoutParameter(rp_RightCenter);
// left bottom
Button* button_LeftBottom = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");
layout->addChild(button_LeftBottom);
RelativeLayoutParameter* rp_LeftBottom = RelativeLayoutParameter::create();
rp_LeftBottom->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_BOTTOM);
button_LeftBottom->setLayoutParameter(rp_LeftBottom);
// bottom center
Button* button_BottomCenter = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");
layout->addChild(button_BottomCenter);
RelativeLayoutParameter* rp_BottomCenter = RelativeLayoutParameter::create();
rp_BottomCenter->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_BOTTOM_CENTER_HORIZONTAL);
button_BottomCenter->setLayoutParameter(rp_BottomCenter);
// right bottom
Button* button_RightBottom = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");
layout->addChild(button_RightBottom);
RelativeLayoutParameter* rp_RightBottom = RelativeLayoutParameter::create();
rp_RightBottom->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_BOTTOM);
button_RightBottom->setLayoutParameter(rp_RightBottom);
0 0
- Cocos2d-x Layout使用三
- Cocos2d-x Layout使用
- Cocos2d-x Layout简单使用
- Cocos2d-x Layout的使用二
- Cocos2d-x layout (二)
- cocos2d-X 节点(Layout.h)API
- (三)cocos2d-x中通过lua脚本使用ccbi
- Cocos2d-x三种定时器的使用schedule,scheduleUpdate,scheduleOnce
- cocos2d-x之三种定时器的使用
- Cocos2d-x 原生EditBox三种形式的使用
- 【Cocos2d-X(2.x) 游戏开发系列之三】最新版本cocos2d-2.0-x-2.0.2使用资源加载策略
- Cocos2d-x--使用Cocos2d-x v3.0.0
- 三.cocos2d-x的基本概念
- (三)认识Cocos2D-X引擎
- Cocos2d-X游戏开发(三)
- cocos2d-x CCTextureCache使用
- Cocos2d-x使用SQLite
- cocos2d-x RTTI使用
- Arduino代码机制-main.cpp
- java日期格式
- STL中的find_if函数 http://blog.csdn.net/hj490134273/article/details/6051080
- Android小笔记(2)
- 插头DP小结
- Cocos2d-x Layout使用三
- 通信框架笔记
- POJ 3177 Redundant Paths 边双联通分量 缩点
- iOS学习----------支付宝咻咻咻
- Android妙用SPDY协议提高移动端网络请求性能
- SAP接口编程-RFC系列11:C#语言调用RFC
- 内心的不安全感
- Python:基础知识
- 新Android反编译教程