Cocos2d-x Layout的使用二
发布时间:2020-12-14 16:54:38 所属栏目:百科 来源:网络整理
导读:Size size = Director::getInstance()-getVisibleSize(); Layout* root = Layout::create(); root-setContentSize(Size(500,400)); root-setLayoutType(LayoutType::ABSOLUTE); root-setPosition(Vec2(size.width /2,size.height /2)); root-setBackGroundIma
Size size = Director::getInstance()->getVisibleSize();
Layout* root = Layout::create(); root->setContentSize(Size(500,400)); root->setLayoutType(LayoutType::ABSOLUTE); root->setPosition(Vec2(size.width /2,size.height /2)); root->setBackGroundImage("green_edit.png"); root->setAnchorPoint(Point(0.5f,0.5f));//设置以root的中心为锚点 root->setBackGroundImageScale9Enabled(true);//这句很重要,设置铺面root this->addChild(root); Button* button = Button::create("animationbuttonnormal.png","animationbuttonpressed.png"); button->setPosition(Vec2(button->getContentSize().width / 2.0f,root->getContentSize().height - button->getContentSize().height / 2.0f)); root->addChild(button); Button* titleButton = Button::create("backtotopnormal.png","backtotoppressed.png"); titleButton->setTitleText("xxxxxxxx"); titleButton->setPosition(Vec2(root->getContentSize().width / 2.0f,root->getContentSize().height / 2.0f)); root->addChild(titleButton); Button* button_scale9 = Button::create("button.png","buttonHighlighted.png"); button_scale9->setScale9Enabled(true); button_scale9->setContentSize(Size(100.0f,button_scale9->getVirtualRendererSize().height)); button_scale9->setPosition(Vec2(root->getContentSize().width - button_scale9->getContentSize().width / 2.0f,button_scale9->getContentSize().height / 2.0f)); root->addChild(button_scale9); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ios – 所有为iTunes Connect构建,导入此构建时出错
- 苹果Swift语言视频教程闪电入门在线观看(..._51CTO学院
- oracle – 使用提示进行查看?
- 哈斯克尔 – 猜猜我的号码,一个单一的头痛
- vb.net – 如何在DataGridViewTextBoxCell和DataGridViewCo
- c# – linq vs ToDictionary()和TryGetValue() – 什么更有
- ruby-on-rails – bootstrap_form错误未定义方法
- 内核kernel以及根文件系统rootfs是如何映射到对应的nand fl
- 如何将查询参数添加到Dart http请求?
- 编译器错误 – 限制表达式中的术语数量?