微信小游戏:pageview 轮播图

 this.pageview = this.node.getComponent(cc.PageView);
 this.node.on('page-turning', this.pageview_callback, this);  //滚动回调
 this.pageview.setCurrentPageIndex(this.pageview_index);//设置到第几页
this.pageview_length = this.pageview.getPages().length;//获取多少pageview
this.pageview.getCurrentPageIndex());//获得当前的页数
const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {
    @property({type: cc.PageView})
    banner:cc.PageView=null;
    @property
    _pageIdx = 0;
    onLoad () {
    }

    start () {       
    }

    onEnable () {
        this.schedule(this.schdulePageView, 5);        
    }

    onDisable () {
        this.unschedule(this.schdulePageView);
    }

    /**
     * 循环播放广告
     */
    schdulePageView () {
        if (this._pageIdx >= this.banner.getPages().length) {
            this._pageIdx = 0;
        }
        this.banner.setCurrentPageIndex(this._pageIdx);
        cc.log(this.banner.getCurrentPageIndex());//获得当前的页数
        this._pageIdx+=1;
    }

    // update (dt) {}

   
}

代码导出为:http://note.youdao.com/noteshare?id=ed1e33093188f6f3c28ef504663fb9df&sub=3E5C420615934CD199D51AC8C599DCE0
下载后,文件-》资源导入

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,724评论 25 709
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,534评论 19 139
  • 用两张图告诉你,为什么你的 App 会卡顿? - Android - 掘金 Cover 有什么料? 从这篇文章中你...
    hw1212阅读 14,484评论 2 59
  • 这两天因为师兄他们的活动心里总是有点觉得有点坑,长长的路慢慢走,慢慢走长长路,所以,我一直告诉自己不应该有情绪毕竟...
    重庆茶人唐天辉阅读 2,726评论 3 8
  • 今天,我登录了这款软件。我将会发布我的作品,希望大家能喜欢!
    平凡的世界zyq阅读 1,235评论 0 0