cocosCreator中PageView自动翻页

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
let pageList = this._view._PageC_List;
let pageCount = pageList.getPages().length; // 获取翻页容器长度
let duration = 3; // 自动翻页时间,s
let currentPageIndex = 0; // 当前页数
let direction = 1; // 翻页方向
let scrollTiem = 1; // 翻页时间
pageList.schedule(()=>{
if(currentPageIndex === pageCount-1){
direction = -1;
}else if(currentPageIndex === 0){
direction = 1;
}
currentPageIndex += direction;
pageList.scrollToPage(currentPageIndex,scrollTiem);
},duration)