[Containers] PageView

Adding A PageView

Drag a PageView from the Widgets section onto the middle canvas.

253

Selecting The PageView

You can select the PageView if it isn't already selected from the Animation Editor at the bottom. The PageView doesn't appear in the resources as it's part of the Scene or other object that you are using.

PageView are used as a way of grouping objects together. To add objects to your PageView you simply drag any object onto the panel. All transformations applied to the PageView will affect it's children as well. The PageView only takes Panels which can contain any other object.

252

Modifying The PageView

You can change the PageView background file. Setting the PageView's background file can be done by double clicking on the section or dragging an image from the Resources section.

To hide the objects inside the PageView that are out of bounds you simply enable Clipping.

357

Accessing The PageView In Code

PageView's can be accessed via their Name or Tag which can be set in the Properties section.

355

To access the PageView from a scene for example, in code it is simple. You either access it as a Node or cast it to a PageView allowing you to use PageView methods along with Node methods.

Node *rootNode = CSLoader::createNode( "Filepath to .csb file" );
this->addChild( rootNode );

// PageView accessed as a node using it's name
Node *pageView = rootNode->getChildByName( "Name set in Cocos Studio" );

// PageView cast to a PageView using it's name
cocos2d::ui::PageView *pageView = ( cocos2d::ui::PageView * )rootNode->getChildByName( "Name set in Cocos Studio" );

// PageView accessed as a node using it's tag
Node *pageView = rootNode->getChildByTag( 5 );

// PageView cast to a PageView using it's tag
cocos2d::ui::PageView *pageView = ( cocos2d::ui::PageView * )rootNode->getChildByTag( 5 );
var rootNode = ccs.load( "Filepath to .json file" );
this.addChild( rootNode.node );

// get the PageView by name
var pageView = rootNode.node.getChildByName( "Name set in Cocos Studio" );

// get the PageView by tag
var pageView = rootNode.node.getChildByTag( 5 );

Note: Cocos2d-JS doesn't require casting to use PageView methods.