3

In Cocos2d while using the UIPinchGestureRecognizer, how do you get the pinch coordinates?

pad
  • 41,040
  • 7
  • 92
  • 166
Rhuntr
  • 37
  • 3

2 Answers2

2
-(void)handlePinchFrom:(UIPinchGestureRecognizer*)recognizer
{
    // How to get the coordinates.
    CGPoint touchLocation = [recognizer locationInView:recognizer.view];
    touchLocation = [[CCDirector sharedDirector] convertToGL:touchLocation];
    touchLocation = [self convertToNodeSpace:touchLocation];

    // How to get the scale.
    float scale = recognizer.scale;
}

... assuming that self is your scene.

Danyal Aytekin
  • 4,106
  • 3
  • 36
  • 44
  • Thanks Danyal, this gave me the midpoint of the pinch was hoping for the finger locations any ideas??? – Rhuntr Dec 01 '11 at 01:57
  • Not sure but one of the answers here discusses it. http://stackoverflow.com/questions/5311197/uipinchgesturerecognizers-touch-locations – Danyal Aytekin Dec 01 '11 at 09:04
0

There's also some gesture code in CMMSimpleFramework. A bit hard to separate - but overall nice work. https://github.com/kimbobv22/CMMSimpleFramework

nhahtdh
  • 55,989
  • 15
  • 126
  • 162
johndpope
  • 5,035
  • 2
  • 41
  • 43