cocos的pageview 滑动起来相当费力每次都要滑倒屏幕的一般才能滑过去
修改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; 就好滑多了 原文链接:https://www.f2er.com/cocos2dx/342986.html