cocos2d-x3.0 相对布局(一)

2dx相对布局和Android非常类似。假设前完成Android它应该是easy入门。

        Size widgetSize = Director::getInstance()->getWinSize();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(widgetSize.width, widgetSize.height));//横向排列,这里相似Android里的线性布局layout->setLayoutType(LAYOUT_RELATIVE);/*以图片为背景*/layout->setBackGroundImageScale9Enabled(true);layout->setBackGroundImage("green_edit.png");layout->setPosition(Point(0,0));addChild(layout);Button* button_TopLeft = Button::create("animationbuttonnormal.png", "animationbuttonpressed.png");layout->addChild(button_TopLeft);RelativeLayoutParameter* rp_TopLeft = RelativeLayoutParameter::create();rp_TopLeft->setAlign(RELATIVE_ALIGN_PARENT_TOP_LEFT);button_TopLeft->setLayoutParameter(rp_TopLeft);//top center horizontalButton* button_TopCenter = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");layout->addChild(button_TopCenter);RelativeLayoutParameter* rp_TopCenter = RelativeLayoutParameter::create();rp_TopCenter->setAlign(RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL);button_TopCenter->setLayoutParameter(rp_TopCenter);Button* button_TopRight = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");layout->addChild(button_TopRight);RelativeLayoutParameter* rp_TopRight = RelativeLayoutParameter::create();rp_TopRight->setAlign(RELATIVE_ALIGN_PARENT_TOP_RIGHT);button_TopRight->setLayoutParameter(rp_TopRight);//left centerButton* button_LeftCenter = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");layout->addChild(button_LeftCenter);RelativeLayoutParameter* rp_LeftCenter = RelativeLayoutParameter::create();rp_LeftCenter->setAlign(RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL);button_LeftCenter->setLayoutParameter(rp_LeftCenter);//centerButton* buttonCenter = Button::create("animationbuttonnormal.png","animationbuttonnormal.png");layout->addChild(buttonCenter);RelativeLayoutParameter* rpCenter = RelativeLayoutParameter::create();rpCenter->setAlign(RELATIVE_CENTER_IN_PARENT);buttonCenter->setLayoutParameter(rpCenter);Button* button_RightCenter = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");layout->addChild(button_RightCenter);RelativeLayoutParameter* rp_RightCenter = RelativeLayoutParameter::create();rp_RightCenter->setAlign(RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL);button_RightCenter->setLayoutParameter(rp_RightCenter);//left bottomButton* button_LeftBottom = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");layout->addChild(button_LeftBottom);RelativeLayoutParameter* rp_LeftBottom = RelativeLayoutParameter::create();rp_LeftBottom->setAlign(RELATIVE_ALIGN_PARENT_LEFT_BOTTOM);button_LeftBottom->setLayoutParameter(rp_LeftBottom);//bottom centerButton* button_BottomCenter = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");layout->addChild(button_BottomCenter);RelativeLayoutParameter* rp_BottomCenter = RelativeLayoutParameter::create();rp_BottomCenter->setAlign(RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL);button_BottomCenter->setLayoutParameter(rp_BottomCenter);Button* button_RightBottom = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");layout->addChild(button_RightBottom);RelativeLayoutParameter* rp_RightBottom = RelativeLayoutParameter::create();rp_RightBottom->setAlign(RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM);button_RightBottom->setLayoutParameter(rp_RightBottom);


转载于:https://www.cnblogs.com/yxwkf/p/5035203.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/375299.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

管理员以标准权限运行时

在XP时代,大多数用户都用一个管理员(administrator)帐号来登录Windows 利用这个账户,用户几乎能没有任何限制的访问重要的系统资源,因为该账户被授予了很高的权限,一旦用这个帐号登录了xp以及xp之前的操作系统,Windows操作系统就会创建一个安全令牌(security token).每当有代码…

HDU 4791 amp; ZOJ 3726 Alice#39;s Print Service (数学 打表)

题目链接: HDU:http://acm.hdu.edu.cn/showproblem.php?pid4791 ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId5072 Problem DescriptionAlice is providing print service, while the pricing doesnt seem to be reasonable, so people using…

夺命雷公狗---ECSHOP---08---商品页的拇改成星星

<strong>用户评价&#xff1a;</strong>{*---------商品评价星星开始----------*}<img src"./images/stars{$goods.comment_rank}.gif" alt"comment rank {$goods.comment_rank}">{*---------商品评价星星结束-------*} 这里主要是要有星…

文件指针

一.移动文件指针 SetFilePointer,hFile,lDistanceToMove,lpDistanceToMoveHigh,dwMoveMethod dwMoveMethod 指明移动的模式 FILE_BEGIN 不管文件处于什么地方,总是从文件的头部开始移动,这时的位置参数相当于指定了一个绝对位置 FILE_CURRENT 从当前的文件指针处开始移…

见证下的自我变化-2014全年总结

又是一年总结季&#xff0c;回过头看看看自己的成长&#xff0c;心里真的是满满的喜悦之情…… 一年前自己的总结博客&#xff1a;http://blog.csdn.net/huo065000/article/details/19632603 半年前自己的总结博客&#xff1a;http://blog.csdn.net/huo065000/article/details/…

【Linux学习篇】This virtual machine is configured for 64-bit guest operating systems.……

在学习Linux的基本操作的时候&#xff0c;安装虚拟环境则提示自己 This virtualmachine is configured for 64-bit guest operatingsystems.……起初由于各种拒绝的心理&#xff0c;所以屏蔽了这个错误&#xff0c;但是屏蔽永远也解决不了问题的&#xff0c;所以自己则尝试百度…

图解SSIS监视文件夹并自动导入数据

图解SSIS监视文件夹并自动导入数据 原文:图解SSIS监视文件夹并自动导入数据 演示案例&#xff1a;让系统自动监视文件夹&#xff0c;并把文件夹下面的excel文件导入到sql中&#xff0c;之后清空目录。这个过程以往都需要写程序来实现或者定时执行&#xff0c;现在可以用ssis来订…

DLL转Lib

在C中,为了允许操作符重载和函数重载,C编译器往往按照某种规则改写每一个入口点的符号名,以便使用同一个名字(具有不同的参数类型或者是不同的作用域)有多种不同的用法,而不会打破现有基于C的链接器,.这项技术通常被称为改编(Name Mangling)或者名称修饰(Name Decoration),许多…

WP8手机解锁时提示“请确保IPOVERUSBSVC服务正常运行”解决方法

如果你各种重启服务 卸载手机 重装驱动都试过了还不行&#xff0c;请看看你是否安装了Hyper-v或Vitualbox虚拟机&#xff0c;很有可能是虚拟交换机造成的。 我在网络连接属性里看到这个 把它卸载后&#xff0c;解锁成功。 解锁后记得重新安装卸载的那个网络服务转载于:https://…

Win32路径操作相关API

一.路径截断与合并 PathRemoveArgs 去除路径的参数 PathRemoveBackslash 去除路径最后的反斜杠 "\" PathAddBackslash 在路径最后加上反斜杠 "\" PathRemoveBlanks 去除路径前后的空格 PathAddExtension 在文件路径后面加上扩展名 PathRemoveExtension 去…

Openjudge-计算概论(A)-称体重

描述&#xff1a; 赵、钱、孙、李四个人中既有大人也有小孩&#xff0c;给他们称体重时发现&#xff0c;他们每个人的体重都不一样&#xff0c;且体重&#xff08;单位&#xff1a;公斤&#xff09;恰好是10的整数倍&#xff0c;且他们的体重都不高 于50公斤&#xff0c;已知赵…

浮点数的存储

-------------------------------------------------------------------------------- 在VC6.0----float环境一共32位 其中第一位是符号位 第二到第9位中间8位为小数点位置&#xff08;指数以127的二进制为原点向下为负指数 向上为正指数&#xff09;后面23位为数据位。 S EE…

第二阶段总结

结合第二阶段后3天&#xff0c;我们试用了UI&#xff0c;antionbar&#xff0c;menu等实用&#xff0c;成功的做出了字体的转换&#xff0c;题目的转化等功能。 其实四则运算&#xff0c;说难不难 说易不易&#xff0c;总结出 主要有付出&#xff0c;就有回报。 menu等做的过程…

const 和指针

c用了那么久&#xff0c;觉得 const 和指针配合到一起的时候就会有点点分不出来。 如下: const Data* pData;Data const * pDataData * const pDataconst Data * const pData Data const * const pData是不是有点晕&#xff1f; 我其实用得最多的是 const Data* pData, 也…

Linux 查看系统用户的登录日志

查看用户登录系统的日志有两类日志记录用户登录的行为&#xff0c;一是记录登录者的数据&#xff0c;一个是记录用户的登录时间一&#xff0c;记录用户登录数据/var/log/wtmp日志文件记录用户登录的数据。但这个文件是被编码的文件&#xff0c;不能直接用vi、cat等命令查看&…

Android -- 自定义权限

在android系统的安全模型中&#xff0c;应用程序在默认的情况下不可以执行任何对其他应用程序&#xff0c;系统或者用户带来负面影响的操作。如果应用需要执行某些操作&#xff0c;就需要声明使用这个操作对应的权限。 &#xff08;在manifest文件中 添加标记&#xff09;。 ap…

Win32 路径操作API

路径操作相关API 路径截断与合并函数 PathRemoveArgs 去除路径的参数 PathRemoveBackslash 去除路径最后的反斜杠“\” PathAddBackslash 在路径最后加上反斜杠“\” PathRemoveBlanks 去除路径前后的空格 PathAddExtension 在文件路径后面加上扩展名 Pa…

dbms_output.put_line长度限制问题

dbms_output.put_line长度限制问题对于10g以上版本(包括10g), dbms_output.put_line的最大长度限制是32767. 如果报错buffer overflow, 执行如下语句即可:set serveroutput ON SIZE UNLIMITED FORMAT WORD_WRAPPED对于10g以下版本dbms_output.put_line最大长度限制是255.转载于…

js深入研究之Person类案例

<script type"text/javascript"> /* 定义一个Person类 */ function Person(name, age) {this.name name;this.age age; } /* 添加两个方法getName getAge */ Person.prototype {getName: function() {return this.name;},getAge: function() {return this.a…

C++名称粉碎

C name mangling 1: ?0: 构造器&#xff0c;?1 析构器 2: QAE: public __thiscall AAE: private __thiscall QBE: public __thiscall const 3: 返回值和参数类型 B&#xff1a;const D&#xff1a;char E&#xff1a;unsigned char F&#xff1a;…