title: Pinching/Panning a CCNode in Cocos2d 3.0
body: <p>I want to zoom in out a CCNode by pinching and panning the screen. The node has a background which is very large but the portionof it shown on the screen. That node also contains other sprites.</p>
  
  <p>What I have done by now is that first I register UIPinchGestureRecognizer</p>
  
  <p>UIPinchGestureRecognizer * pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchFrom:)];
  [[[CCDirector sharedDirector] view] addGestureRecognizer: pinchRecognizer];</p>
  
  <pre><code>-(void)handlePinchFrom:(UIPinchGestureRecognizer *) pinch
  {
      if(pinch.state == UIGestureRecognizerStateEnded) {
          prevScale = 1;
      }
      else {
          CGFloat dscale = [self scale] - prevScale + pinch.scale;
          if(dscale &gt; 0)
          {
              deltaScale = dscale;
          }
          CGAffineTransform transform = CGAffineTransformScale(pinch.view.transform, deltaScale, deltaScale);
          [pinch.view setTransform: transform];
  
  //        [_contentNode setScale:deltaScale];
  
          prevScale = pinch.scale;
      }
  }
  </code></pre>
  
  <p>The problem is that it scalw whole UIView not the CCNode. I have also tried to by setting the scale of my _contentNode.</p>
  
  <p><strong>**EDIT</strong></p>
  
  <p>I ave also tried this </p>
  
  <pre><code>- (void)handlePinchGesture:(UIPinchGestureRecognizer*)aPinchGestureRecognizer
  {
  
  if (pinch.state == UIGestureRecognizerStateBegan || pinch.state == UIGestureRecognizerStateChanged) {
      CGPoint midpoint = [pinch locationInView:[CCDirector sharedDirector].view];
      CGSize winSize = [CCDirector sharedDirector].viewSize;
      float x = midpoint.x/winSize.width;
      float y = midpoint.y/winSize.height;
      _contentNode.anchorPoint = CGPointMake(x, y);
      float scale = [pinch scale];
      _contentNode.scale *= scale;
      pinch.scale = 1;
  }
  }
  </code></pre>
  
  <p>But it zoom from the bottom left of the screen.</p>