如何在cocos2d v3中停止滚动CCScrollView对象的动画

时间:2014-08-11 20:40:21

标签: ios animation cocos2d-iphone scroll ccscrollview

在iOS的cocos2d v3应用程序中,我遇到了如何停止滚动CCScrollView对象动画的误解。我已尝试过对其方法的一些调用组合,但没有成功,例如

[_scrollView setScrollPosition:_scrollView.scrollPosition animated:NO];
[_scrollView stopAllActions];
[_dataListNode stopAllActions];

其中_dataListNode是CCScrollView的ContentNode

正确的方法是什么?

2 个答案:

答案 0 :(得分:1)

通过修补CCScrollView对象来停止滚动动画的唯一方法

// reveal hidden velocity property
@property (nonatomic, assign) CGPoint velocity;
// this forces animation to stop
_scrollView.velocity = CGPointZero;

我仍在寻找更好的方法

答案 1 :(得分:1)

CCScrollView是ScrollView(cocos2d-x v3)有一个方法setContentOffsetInDuration 所以

svContent->setContentOffsetInDuration(svContent->getContentOffset(), 0.001f);

会做的伎俩。请注意,持续时间 - 0.001f是我放置的小到足以看到动画几乎是即时的。