0

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);

} 
Community
  • 1
  • 1
ahicks
  • 1
  • 1

1 Answers1

2

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;
lucianomarisi
  • 1,552
  • 11
  • 24
  • `@property (nonatomic,assign) BOOL pagingEnabled;` I'll give this a try, the other methods I was using to set `pagingEnabled` didn't seem to want to be working. – ahicks May 24 '14 at 05:35
  • I tried your suggestion and my paging is still disabled for whatever reason. I uploaded some of the code. I'm mostly self taught, so I might just be totally missing something simple to do with delegates :/ – ahicks May 24 '14 at 05:44