0

I have a CCScrollLayer in my app which contains movable sprites (they can be dragged & dropped). The issue is that when dragging the sprites too far, the CCScrollLayer starts scrolling. I am trying to disable the CCScrollLayer from scrolling as long as I am dragging those sprites. The disabling works by using

[[CCTouchDispatcher sharedDispatcher] removeDelegate:sender];

I get the sender from method

- (void)scrollLayerScrollingStarted:(CCScrollLayer *)sender {
    //...
}

I cannot enable the CSScrollLayer again, tried with this but no result:

[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:scrollLayer priority:0 swallowsTouches:NO];

I am using v1.0.1 (stable version)

Guru
  • 21,652
  • 10
  • 63
  • 102
mmvie
  • 2,571
  • 7
  • 24
  • 39
  • I found this as well: http://code.google.com/p/cocos2d-iphone/issues/detail?id=1267 which states an official bug report. Using the CCTouchDispatcher from there does not work. Does anybody have a work around? – mmvie Jun 25 '12 at 21:08

1 Answers1

1

You could subclass CCScrollLayer and add an enabled property boolean. Just override the touch methods that CCScrollLayer uses to start its sliding. For example

-(BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
     if(self.enabled)
           return [super ccTouchBegan:touch withEvent:event];
     else
           return NO;
}
Ben Trengrove
  • 8,191
  • 3
  • 40
  • 58