220 Size widgetSize =
_widget->getContentSize();
223 _displayValueLabel = Text::create(
"Move by any direction",
"fonts/Marker Felt.ttf",32);
229 Text* alert = Text::create(
"ScrollView both",
"fonts/Marker Felt.ttf",30);
230 alert->setColor(Color3B(159, 168, 176));
231 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
234 Layout* root =
static_cast<Layout*
>(
_uiLayer->getChildByTag(81));
236 Layout* background =
static_cast<Layout*
>(root->getChildByName(
"background_Panel"));
239 ui::ScrollView* scrollView = ui::ScrollView::create();
240 scrollView->setDirection(ui::ScrollView::Direction::BOTH);
241 scrollView->setTouchEnabled(
true);
242 scrollView->setBounceEnabled(
true);
243 scrollView->setBackGroundImageScale9Enabled(
true);
244 scrollView->setBackGroundImage(
"cocosui/green_edit.png");
245 scrollView->setContentSize(Size(210, 122.5));
246 scrollView->setScrollBarWidth(4);
247 scrollView->setScrollBarPositionFromCorner(Vec2(6, 6));
248 Size backgroundSize = background->getContentSize();
249 scrollView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
250 (backgroundSize.width - scrollView->getContentSize().width) / 2.0f,
251 (widgetSize.height - backgroundSize.height) / 2.0f +
252 (backgroundSize.height - scrollView->getContentSize().height) / 2.0f));
253 ImageView* imageView = ImageView::create(
"Hello.png");
254 scrollView->addChild(imageView);
256 scrollView->setInnerContainerSize(imageView->getContentSize());
257 Size innerSize = scrollView->getInnerContainerSize();
258 imageView->setPosition(Vec2(innerSize.width / 2.0f, innerSize.height / 2.0f));
263 scrollView->jumpToBottomRight();
cocos2d::Layer * _uiLayer
virtual bool init() override
cocos2d::ui::Layout * _widget