Cocos2d-x Layout的使用二

前端之家收集整理的这篇文章主要介绍了Cocos2d-x Layout的使用二前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
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); 原文链接:https://www.f2er.com/cocos2dx/340187.html

猜你在找的Cocos2d-x相关文章