cocos2d js Pageview的用法

前端之家收集整理的这篇文章主要介绍了cocos2d js Pageview的用法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

代码一目了然


WINSIZE = cc.director.getWinSize();
var p1 = new cc.Sprite(res.p1);
var p2 = new cc.Sprite(res.p2);
var p3 = new cc.Sprite(res.p3);

p1.x = WINSIZE.width/2;
p1.y = WINSIZE.height/2;

p2.x = WINSIZE.width/2;
p2.y = WINSIZE.height/2;

p3.x = WINSIZE.width/2;
p3.y = WINSIZE.height/2;

var pageView = new ccui.PageView();
pageView.setTouchEnabled(true);
pageView.setSize(cc.size(640,1136));

var layout =new ccui.Layout();
layout.setSize(cc.size(640,1136));
layout.addChild(p1);
var layout2 = new ccui.Layout();
layout2.setSize(cc.size(640,1136));
layout2.addChild(p2);
var layout3 = new ccui.Layout();
layout3.setSize(cc.size(640,1136));
layout3.addChild(p3);

pageView.addPage(layout);
pageView.addPage(layout2);
pageView.addPage(layout3);

this.addChild(pageView);
pageView.scrollToPage(0);

猜你在找的Cocos2d-x相关文章