504 Size widgetSize =
_widget->getContentSize();
507 _displayValueLabel = Text::create(
"Move by vertical direction",
"fonts/Marker Felt.ttf", 32);
514 Text* alert = Text::create(
"ScrollView vertical",
"fonts/Marker Felt.ttf", 30);
515 alert->setColor(Color3B(159, 168, 176));
516 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
519 Layout* root =
static_cast<Layout*
>(
_uiLayer->getChildByTag(81));
521 Layout* background =
dynamic_cast<Layout*
>(root->getChildByName(
"background_Panel"));
524 ui::ScrollView* scrollView = ui::ScrollView::create();
525 scrollView->setContentSize(Size(280.0f, 150.0f));
526 scrollView->setDirection(ui::ScrollView::Direction::VERTICAL);
527 Size backgroundSize = background->getContentSize();
528 scrollView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
529 (backgroundSize.width - scrollView->getContentSize().width) / 2.0f,
530 (widgetSize.height - backgroundSize.height) / 2.0f +
531 (backgroundSize.height - scrollView->getContentSize().height) / 2.0f + 100) );
532 scrollView->setRotation(45);
533 scrollView->setScrollBarPositionFromCorner(Vec2(4, 4));
534 scrollView->setScrollBarColor(Color3B::WHITE);
537 ImageView* imageView = ImageView::create(
"cocosui/ccicon.png");
539 float innerWidth = scrollView->getContentSize().width;
540 float innerHeight = scrollView->getContentSize().height + imageView->getContentSize().height;
542 scrollView->setInnerContainerSize(Size(innerWidth, innerHeight));
544 Button* button = Button::create(
"cocosui/animationbuttonnormal.png",
"cocosui/animationbuttonpressed.png");
545 button->setPosition(Vec2(innerWidth / 2.0f, scrollView->getInnerContainerSize().height - button->getContentSize().height / 2.0f));
546 scrollView->addChild(button);
548 Button* titleButton = Button::create(
"cocosui/backtotopnormal.png",
"cocosui/backtotoppressed.png");
549 titleButton->setTitleText(
"Title Button");
550 titleButton->setPosition(Vec2(innerWidth / 2.0f, button->getBottomBoundary() - button->getContentSize().height));
551 scrollView->addChild(titleButton);
553 Button* button_scale9 = Button::create(
"cocosui/button.png",
"cocosui/buttonHighlighted.png");
554 button_scale9->setScale9Enabled(
true);
555 button_scale9->setContentSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
556 button_scale9->setPosition(Vec2(innerWidth / 2.0f, titleButton->getBottomBoundary() - titleButton->getContentSize().height));
557 scrollView->addChild(button_scale9);
559 imageView->setPosition(Vec2(innerWidth / 2.0f, imageView->getContentSize().height / 2.0f));
560 scrollView->addChild(imageView);
cocos2d::Layer * _uiLayer
virtual bool init() override
cocos2d::ui::Layout * _widget