1

In my cocos2d v3 app for iOS I ran into misunderstanding of how to stop scrolling animation of CCScrollView object. I have tried some combinations of calls to its methods with no success, like

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

where _dataListNode is a ContentNode of CCScrollView

What is the correct way?

duganets
  • 1,853
  • 5
  • 20
  • 31
  • So are you basically saying you want your scrollview to scroll along, then once it hits a certain position it stops scrolling for whatever reason? If so, have you tried creating a CGPoint right when it gets to that point, equating it to the scrollview's position, and then setting the scrollview to that position? I'm not sure if setting the scrollview to its own position really works...Let me know if you give that a try – spaderdabomb Aug 12 '14 at 02:14
  • You also might want to try a combination of setting the properties "setInertiaScrollEnabled" and "touchEnabled" to false...I would imagine it would immediately stop scrolling at that point, and then you would also no longer be able to scroll it since it isn't touch enabled – spaderdabomb Aug 12 '14 at 02:20

2 Answers2

1

The only way to stop scrolling animation which I have found by patching CCScrollView object

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

I am still searching for better way

duganets
  • 1,853
  • 5
  • 20
  • 31
1

CCScrollView which is ScrollView(cocos2d-x v3) has a method setContentOffsetInDuration So

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

Would do the trick. Please be noticed that the duration - 0.001f is what I put as a small enough to see the animation almost instant.

Lucas Leon
  • 114
  • 4