286 Size widgetSize =
_widget->getContentSize();
295 Text* alert = Text::create(
"ScrollView scroll to percent both direction without scroll bar",
"fonts/Marker Felt.ttf",20);
296 alert->setColor(Color3B(159, 168, 176));
297 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 4.5));
300 Layout* root =
static_cast<Layout*
>(
_uiLayer->getChildByTag(81));
302 Layout* background =
static_cast<Layout*
>(root->getChildByName(
"background_Panel"));
304 ui::ScrollView* sc = ui::ScrollView::create();
305 sc->setBackGroundColor(Color3B::GREEN);
306 sc->setBackGroundColorType(Layout::BackGroundColorType::SOLID);
307 sc->setDirection(ui::ScrollView::Direction::BOTH);
308 sc->setInnerContainerSize(Size(480.0f, 320.0f));
309 sc->setContentSize(Size(100.0f,100.0f));
310 sc->setScrollBarEnabled(
false);
311 Size backgroundSize = background->getContentSize();
312 sc->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
313 (backgroundSize.width - sc->getContentSize().width) / 2.0f,
314 (widgetSize.height - backgroundSize.height) / 2.0f +
315 (backgroundSize.height - sc->getContentSize().height) / 2.0f));
316 sc->scrollToPercentBothDirection(Vec2(50, 50), 1,
true);
317 ImageView* iv = ImageView::create(
"cocosui/Hello.png");
318 iv->setPosition(Vec2(240.0f, 160.0f));
cocos2d::Layer * _uiLayer
virtual bool init() override
cocos2d::ui::Layout * _widget