1011 Size widgetSize =
_widget->getContentSize();
1014 _displayValueLabel = Text::create(
"PageView indicator custom texture\nscale : 0.5, index color: RED",
"fonts/Marker Felt.ttf", 16);
1017 widgetSize.height / 2.0f +
1022 Text* alert = Text::create(
"PageView",
"fonts/Marker Felt.ttf", 30);
1023 alert->setColor(Color3B(159, 168, 176));
1024 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
1027 Layout* root =
static_cast<Layout*
>(
_uiLayer->getChildByTag(81));
1029 Layout* background =
dynamic_cast<Layout*
>(root->getChildByName(
"background_Panel"));
1032 PageView* pageView = PageView::create();
1033 pageView->setContentSize(Size(240.0f, 130.0f));
1034 Size backgroundSize = background->getContentSize();
1035 pageView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
1036 (backgroundSize.width - pageView->getContentSize().width) / 2.0f,
1037 (widgetSize.height - backgroundSize.height) / 2.0f +
1038 (backgroundSize.height - pageView->getContentSize().height) / 2.0f));
1039 pageView->setDirection(ui::PageView::Direction::VERTICAL);
1040 pageView->removeAllItems();
1042 pageView->setIndicatorEnabled(
true);
1043 pageView->setIndicatorSpaceBetweenIndexNodes(5);
1044 pageView->setIndicatorIndexNodesScale(0.5);
1045 pageView->setIndicatorIndexNodesTexture(
"cocosui/green_edit.png");
1046 pageView->setIndicatorIndexNodesColor(Color3B::RED);
1049 for (
int i = 0; i < pageCount; ++i)
1051 Layout* layout = Layout::create();
1052 layout->setContentSize(Size(240.0f, 130.0f));
1054 ImageView* imageView = ImageView::create(
"cocosui/scrollviewbg.png");
1055 imageView->setScale9Enabled(
true);
1056 imageView->setContentSize(Size(240.0f, 130.0f));
1057 imageView->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f));
1058 layout->addChild(imageView);
1060 Text* label = Text::create(StringUtils::format(
"page %d",(i+1)),
"fonts/Marker Felt.ttf", 30);
1061 label->setColor(Color3B(192, 192, 192));
1062 label->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f));
1063 layout->addChild(label);
1065 pageView->insertCustomItem(layout, i);
cocos2d::Layer * _uiLayer
virtual bool init() override
cocos2d::ui::Layout * _widget