@maleking wrote:
Hello everyone i want to create a level selection scene with pageview but my problem is there are level button in left of screen and i can't set positon of first column of level icons in 1/4 of screen width how i can do that?
ui::PageView * pageView = ui::PageView::create(); pageView->setTouchEnabled(true); pageView->setAnchorPoint(Vec2(0,.5)); pageView->setContentSize(Size(visibleSize.width/2, visibleSize.height/2 )); pageView->setPosition(Size(0, visibleSize.height / 2)); for (int i = 0; i < 2; ++i) { ui::HBox* outerBox = ui::HBox::create(); outerBox->setContentSize(Size(100, 100)); outerBox->setPosition(Size(visibleSize.height/2, 700)); outerBox->setBackGroundColor(Color3B(3, 50, 244)); float m = visibleSize.width / 7; for (int k = 0; k < 4; ++k) { ui::VBox* innerBox = ui::VBox::create(); innerBox->setPosition(Vec2(visibleSize.width / 2, 30)); innerBox->setColor(Color3B(3, 169, 244)); for (int j = 0; j < 5; j++) { ui::Button *btn = ui::Button::create("ball.png", "ball.png"); btn>addTouchEventListener(CC_CALLBACK_2(HelloWorld::onButtonClicked, this)); btn->setColor(Color3B(3, 169, 244)); btn->setPosition(Vec2(300, 50)); innerBox->setScale(m / btn->getContentSize().width); innerBox->addChild(btn); } ui::LinearLayoutParameter *parameter = ui::LinearLayoutParameter::create(); parameter->setMargin(ui::Margin(0, 0, m, m)); innerBox->setLayoutParameter(parameter); innerBox->setPosition(Vec2(50, 50)); outerBox->addChild(innerBox); } pageView->insertPage(outerBox, i); }
Posts: 1
Participants: 1