cocos的pageview 滑动起来相当费力每次都要滑倒屏幕的一般才能滑过去
我们直接修改cocos的源码就可以达到优化的效果
修改cocos/ui/UIPageView.cpp中的void PageView::handleReleaseLogic(Touch *touch)函数
void PageView::handleReleaseLogic(Touch *touch) { if (this->getPageCount() <= 0) { return; } Widget* curPage = dynamic_cast<Widget*>(this->getPages().at(_curPageIdx)); if (curPage) { Vec2 curPagePos = curPage->getPosition(); ssize_t pageCount = this->getPageCount(); float curPageLocation = curPagePos.x; float pageWidth = getContentSize().width; if (!_usingCustomScrollThreshold) { <span style="color:#ff0000;">_customScrollThreshold = pageWidth / 2.0;</span> } float boundary = _customScrollThreshold; if (curPageLocation <= -boundary) { if (_curPageIdx >= pageCount-1) { scrollPages(-curPageLocation); } else { scrollToPage(_curPageIdx+1); } } else if (curPageLocation >= boundary) { if (_curPageIdx <= 0) { scrollPages(-curPageLocation); } else { scrollToPage(_curPageIdx-1); } } else { scrollToPage(_curPageIdx); } } }
<span style="color:#ff0000;">_customScrollThreshold = pageWidth / 2.0;</span>修改这行代码就可以改变滑动的距离 把它改为_customScrollThreshold = pageWidth / 6.0; 就好滑多了
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。