Cocos2d-x Layout使用

前端之家收集整理的这篇文章主要介绍了Cocos2d-x Layout使用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Size size = Director::getInstance()->getVisibleSize();
Layout* layout = Layout::create();
layout->setContentSize(Size(300,200));
layout->setBackGroundColorType(LAYOUT_COLOR_SOLID);
//layout->setSize(Size(300,200));
layout->setAnchorPoint(Point(0.5f,0.5f));
layout->setBackGroundColor(Color3B::BLUE);
layout->setPosition(Point(size.width/2,size.height/2));
this->addChild(layout);


Button* button = Button::create("animationbuttonnormal.png","animationbuttonpressed.png");
button->setPosition(Vec2(0,0));
button->setAnchorPoint(Vec2(0,0));
layout->addChild(button);


Button* titleButton = Button::create("backtotopnormal.png","backtotoppressed.png");
titleButton->setTitleText("Title Button");
titleButton->setPosition(Vec2( layout->getContentSize().width/2,layout->getContentSize().height/2)); layout->addChild(titleButton); Button* button_scale9 = Button::create("button.png","buttonHighlighted.png"); button_scale9->setScale9Enabled(true); button_scale9->setContentSize(Size(200,button_scale9->getVirtualRendererSize().height)); button_scale9->setPosition(Vec2(layout->getContentSize().width - button_scale9->getContentSize().width /2,layout->getContentSize().height - button_scale9->getContentSize().height /2)); layout->addChild(button_scale9); 原文链接:https://www.f2er.com/cocos2dx/340188.html

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