806 Size widgetSize =
_widget->getContentSize();
809 _displayValueLabel = Text::create(
"Scrolling stop isn't scheduled",
"fonts/Marker Felt.ttf", 32);
815 Text* alert = Text::create(
"Click the button and start to scroll",
"fonts/Marker Felt.ttf", 30);
816 alert->setColor(Color3B(159, 168, 176));
817 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
820 Layout* root =
static_cast<Layout*
>(
_uiLayer->getChildByTag(81));
822 Layout* background =
static_cast<Layout*
>(root->getChildByName(
"background_Panel"));
826 _scrollView->setDirection(ui::ScrollView::Direction::BOTH);
829 _scrollView->setBackGroundImageScale9Enabled(
true);
830 _scrollView->setBackGroundImage(
"cocosui/green_edit.png");
833 _scrollView->setScrollBarPositionFromCorner(Vec2(6, 6));
834 Size backgroundSize = background->getContentSize();
835 _scrollView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
836 (backgroundSize.width -
_scrollView->getContentSize().width) / 2.0f,
837 (widgetSize.height - backgroundSize.height) / 2.0f +
838 (backgroundSize.height -
_scrollView->getContentSize().height) / 2.0f));
839 ImageView* imageView = ImageView::create(
"Hello.png");
841 _scrollView->setInnerContainerSize(imageView->getContentSize());
842 Size innerSize =
_scrollView->getInnerContainerSize();
843 imageView->setPosition(Vec2(innerSize.width / 2.0f, innerSize.height / 2.0f));
847 _scrollView->addEventListener([&] (Ref*, ui::ScrollView::EventType e)
851 case ui::ScrollView::EventType::SCROLLING_BEGAN:
852 CCLOG(
"scrolling began!");
854 case ui::ScrollView::EventType::SCROLLING_ENDED:
855 CCLOG(
"scrolling ended!");
857 case ui::ScrollView::EventType::AUTOSCROLL_ENDED:
858 CCLOG(
"auto-scrolling ended!");
868 Button* button_scale9 = Button::create(
"cocosui/button.png",
"cocosui/buttonHighlighted.png");
869 button_scale9->setTitleText(
"Stop scrolling in 3 sec.");
870 button_scale9->setScale9Enabled(
true);
871 button_scale9->setContentSize(Size(120.0f, button_scale9->getVirtualRendererSize().height));
872 button_scale9->setPosition(Vec2(innerSize.width / 2.0f, innerSize.height / 2.0f));
873 button_scale9->addClickEventListener([
this] (Ref*) { this->
_remainingTime = 3.0f; });
877 Director::getInstance()->getScheduler()->scheduleUpdate(
this, 0,
false);
cocos2d::Layer * _uiLayer
virtual bool init() override
cocos2d::ui::Layout * _widget