手册:
scrollToPercentHorizontal(float percent, float time, bool attenuated);//水平滚动容器内容到滚动视图宽度百分比位置上
然而这并没有什么卵用。
笔记:
第一个参数percent将使内部容器向左滚动(内部容器宽度 - 滚动层宽度) * percent 像素的距离
第二个参数time为滚动时间,单位为秒
第三个参数attenuated为true时使滚动过程拥有减速效果
所以想要使内部容器0.5s内减速向左滚动x像素可以调用
float percent = 100.0f * x / (scroll->getInnerContainerSize().width - scroll->getContentSize().width) scroll->scrollToPercentHorizontal(percent, 0.5f, true);
作为回调
#include <iostream>
using namespace std;
class Clz{};
typedef void (Clz::*pot)();
class Sub : public Clz{
public:
void test(){cout<<"test"<<endl;}
pot pFun;
void testCallback(){(this->*pFun)();}
};
int main() {
// your code goes here
Sub* sub = new Sub();
sub->pFun = pot(&Sub::test);
sub->testCallback();
delete sub;
return 0;
}