59 Size widgetSize =
_widget->getContentSize();
62 _displayValueLabel = Text::create(
"Move by vertical direction",
"fonts/Marker Felt.ttf", 32);
69 Text* alert = Text::create(
"ScrollView vertical",
"fonts/Marker Felt.ttf", 30);
70 alert->setColor(Color3B(159, 168, 176));
71 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
74 Layout* root =
static_cast<Layout*
>(
_uiLayer->getChildByTag(81));
76 Layout* background =
dynamic_cast<Layout*
>(root->getChildByName(
"background_Panel"));
79 ui::ScrollView* scrollView = ui::ScrollView::create();
80 scrollView->setContentSize(Size(280.0f, 100.0f));
81 Size backgroundSize = background->getContentSize();
82 scrollView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
83 (backgroundSize.width - scrollView->getContentSize().width) / 2.0f,
84 (widgetSize.height - backgroundSize.height) / 2.0f +
85 (backgroundSize.height - scrollView->getContentSize().height) / 2.0f));
86 scrollView->setScrollBarWidth(4);
87 scrollView->setScrollBarPositionFromCorner(Vec2(2, 2));
88 scrollView->setScrollBarColor(Color3B::WHITE);
89 scrollView->setGlobalZOrder(200);
92 ImageView* imageView = ImageView::create(
"cocosui/ccicon.png");
94 float innerWidth = scrollView->getContentSize().width;
95 float innerHeight = scrollView->getContentSize().height + imageView->getContentSize().height;
97 scrollView->setInnerContainerSize(Size(innerWidth, innerHeight));
99 Button* button = Button::create(
"cocosui/animationbuttonnormal.png",
"cocosui/animationbuttonpressed.png");
100 button->setPosition(Vec2(innerWidth / 2.0f, scrollView->getInnerContainerSize().height - button->getContentSize().height / 2.0f));
101 scrollView->addChild(button);
103 Button* titleButton = Button::create(
"cocosui/backtotopnormal.png",
"cocosui/backtotoppressed.png");
104 titleButton->setTitleText(
"Title Button");
105 titleButton->setPosition(Vec2(innerWidth / 2.0f, button->getBottomBoundary() - button->getContentSize().height));
106 scrollView->addChild(titleButton);
108 Button* button_scale9 = Button::create(
"cocosui/button.png",
"cocosui/buttonHighlighted.png");
109 button_scale9->setScale9Enabled(
true);
110 button_scale9->setContentSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
111 button_scale9->setPosition(Vec2(innerWidth / 2.0f, titleButton->getBottomBoundary() - titleButton->getContentSize().height));
112 scrollView->addChild(button_scale9);
114 imageView->setPosition(Vec2(innerWidth / 2.0f, imageView->getContentSize().height / 2.0f));
115 scrollView->addChild(imageView);
116 scrollView->scrollToBottom(2.0,
true);
cocos2d::Layer * _uiLayer
virtual bool init() override
cocos2d::ui::Layout * _widget