关于pageView组件的问题

zzf_2025
Wed, 23 Jan 2019 08:27:28 +0000

写得简单了些。你试试，我加入了对象池来提升性能。

        var _pool = new cc.NodePool();
        this.pageView.node.on('scroll-began', () => {
            if (this.pageView.getCurrentPageIndex() == this.pageView.content.childrenCount - 1) {
                if (!this.newPage) {
                    this.newPage = cc.instantiate(this.pageView.getPages()[0]);
                }
                this.pageView.addPage(this.newPage);

            }
        });

        this.pageView.node.on('scroll-ended', () => {
            if (this.pageView.getPages().length == 4) {
                _pool.put(this.pageView.content.children[1]);
                this.newPage = _pool.get();
                this.pageView._pages.splice(1, 1);
                this.pageView._updatePageView();
            }
        })

阅读整个主题