#include "PageViewScene.h"
Scene* PageViewScene::createScene()
auto scene = Scene::create();
auto layer = PageViewScene::create();
// on "init" you need to initialize your instance
bool PageViewScene::init()
if ( !Layer::init() ) return false;
auto windowSize = Director::getInstance()->getWinSize();
//PageViewを作成これにレイアウトを追加していく
auto pageView = PageView::create();
pageView->setTouchEnabled(true);
pageView->setSize(windowSize);
for (int i = 0; i < 40; i++) {
auto layout = Layout::create();
layout->setSize(windowSize);
auto imageView = ImageView::create("BattleSceneLayout/stage/BackGround_001.png");
imageView->setAnchorPoint( Point::ANCHOR_BOTTOM_LEFT );
imageView->setScale(2.0f);
layout->addChild(imageView);
auto label = Text::create(StringUtils::format("%dページ",(i+1)), "fonts/Marker Felt.ttf", 30);
label->setColor(Color3B(Color3B::BLUE));
label->setPosition(Point(layout->getSize().width / 2, layout->getSize().height / 2));
pageView->addPage(layout);
//イベントリスナーを追加(using namespace ui; しないと参照出来ないので注意)
pageView->addEventListenerPageView(this, pagevieweventselector(PageViewScene::pageviewCallBack));
this->addChild(pageView);
void PageViewScene::pageviewCallBack(Ref* sender, PageViewEventType type)
if(type == PAGEVIEW_EVENT_TURNING){
auto pageView = dynamic_cast<PageView*>(sender);
log("%ld",pageView->getCurPageIndex() + 1);