cocos2d-iphone-extensions icon indicating copy to clipboard operation
cocos2d-iphone-extensions copied to clipboard

CCLayerPanZoom: Enable and disabling touches

Open praveencastelino opened this issue 12 years ago • 2 comments

There are no methods to enable and disable touches.

praveencastelino avatar Feb 29 '12 10:02 praveencastelino

I have used the following solution which works fine...

-(void)enableTouch:(BOOL)enable { if(enable) { [[CCTouchDispatcher sharedDispatcher] addStandardDelegate:self priority:0]; } else { [[CCTouchDispatcher sharedDispatcher] removeDelegate:self]; } }

praveencastelino avatar Feb 29 '12 12:02 praveencastelino

When implementing what praveencastelino suggested, I had to in addition remove all objects from the touches array of the PanZoomLayer:

 -(void)enableTouches:(BOOL)enable
{
    [[self touches] removeAllObjects];
    if(enable)
    {
        [[CCTouchDispatcher sharedDispatcher] addStandardDelegate:self priority:0];
        CCLOG(@"LayerPanZoom enabled.");
    }
    else
    {
        [[CCTouchDispatcher sharedDispatcher] removeDelegate:self];
        CCLOG(@"LayerPanZoom disabled.");
    }
}

If I didn't it had lot's of problems when resuming touch handling.

jtarallo avatar May 22 '12 05:05 jtarallo