Reputation: 1
I'm using CCScrollView
to create a paging level select screen that is popular in many puzzle games. However, I would like to be able to detect when paging occurs. Right now, my code creates a paging view exactly as I want it to, however, I am not able to detect changes.
I know that in order to do that, I must use CCScrollViewDelegate
. It seems that as soon as I make it a delegate I lose the snap paging that I want (i.e. it becomes a constant scroll.)
I'll happily upload any code anybody would like to see. I set up everything that is suggested here. Except instead of using didLoadFromCCB
, I used onEnter
(since I'm not using any CCBs)
The onEnter code, ideally setting up the delegate and the property.
- (void) onEnter {
_groupSelect.delegate = self;
self.pagingEnabled = true;
}
Code that should log out the page number, which it successfully does, but on a continuous scroll, not a paging.
- (void) scrollViewDidScroll:(CCScrollView *)scrollView {
NSLog(@"%i", self.groupSelect.horizontalPage);
}
Upvotes: 0
Views: 683
Reputation: 1552
You can use one of the delegate methods of CCScrollView
, for example:
- (void)scrollViewDidEndDecelerating:(TBRCarousel *)scrollView
{
int currentPage = scrollView.horizontalPage;
}
Also make sure you set the pagingEnabled
property to YES
@property (nonatomic,assign) BOOL pagingEnabled;
Upvotes: 2