0

Let me first introduce you to the node hierarchy:

SKView->SKScene->SKNode

I've added a UIPinchGestureRecognizer to the view so that I can zoom in and out my content. Here's the code in SKScene object:

-(void)handlePinch:(UIPinchGestureRecognizer*)pinchRecognizer{
    [self runAction:[SKAction scaleBy:pinchRecognizer.scale duration:0]];
    pinchRecognizer.scale = 1;
}

Everything's OK except for two things:

  1. In my node's touch events I check the position of the touch and act accordingly. Everything works fine as long as the scale of the scene is untouched. But if I zoom in or out I can no more do this. It's because even if I seem to touch the same point on the screen it's actually different before and after zooming. In Cocos2D I had exactly the same problem. But I could solve this problem by just converting the touch point to node space with convertToNodeSpace method. There should be an equivalent in Sprite Kit. What is it?
  2. When pinching, anchor point is the lower left corner. Is there a way to make it zoom from where the pinching occurs?
CodeSmile
  • 64,284
  • 20
  • 132
  • 217
Mikayil Abdullayev
  • 12,117
  • 26
  • 122
  • 206
  • there's an API (reference) for that... https://developer.apple.com/library/ios/documentation/SpriteKit/Reference/SKNode_Ref/Reference/Reference.html#//apple_ref/occ/instm/SKNode/convertPoint:fromNode: – CodeSmile Feb 15 '14 at 20:29
  • Once again Stefen comes for the rescue. I'm aware of convertPoint:fromNode: and convertPoint:toNode: methods but believe me I just can't figure out how to benefit these in order to solve the above mentioned problem. – Mikayil Abdullayev Feb 15 '14 at 20:37

0 Answers0