Cocoa touch 启用多点触摸。。。需要有关存储第二次触摸的帮助吗

Cocoa touch 启用多点触摸。。。需要有关存储第二次触摸的帮助吗,cocoa-touch,cocos2d-iphone,touch,Cocoa Touch,Cocos2d Iphone,Touch,需要能够存储2个触摸,我怎么做我怎么不知道 这就是我做单触的方式 - (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { /////checks whether the screen has been touched and stores its location and converts the coordinates to be avaible for use//// UITouch* myTouch = [

需要能够存储2个触摸,我怎么做我怎么不知道

这就是我做单触的方式

- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

/////checks whether the screen has been touched and stores its location and converts the coordinates to be avaible for use////
UITouch* myTouch = [touches anyObject];
CGPoint locationLeft = [myTouch locationInView: [myTouch view]];
locationLeft = [[CCDirector sharedDirector]convertToGL:locationLeft];
我如何存储第二次触摸


提前感谢

你有没有尝试过像这样重复这些触摸

for (UITouch *touch in touches){
    CGPoint location = [touch locationInView:[touch view]];
    location = [[CCDirector sharedDirector] convertToGL:location];
    location = [self convertToNodeSpace:location];

当您需要处理多点触摸时,应使用
cctouchStart
(注意单数的“touch”而不是“touch”)。(IMO人员应该放弃CCtouchBegind/Moved/End,只使用CCtouchBegind/Moved/End)

每次触摸都会调用CCTouchStart/Moved/End,这意味着您可以轻松区分多个触摸。例如:

- (void)registerWithTouchDispatcher {
   [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:1 swallowsTouches:YES]; 
}

- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
   if (self.firstTouch == nil) {
      // we got the first touch
      self.firstTouch = touch;
   }
   else if (self.secondTouch == nil) {
      // we got the second touch
      self.secondTouch = touch;
   }
   // return YES to consume the touch (otherwise it'll cascade down the layers)
   return YES;
}

- (void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event {
   if (touch == self.firstTouch) {
      // we got the first touch
      // do stuff
   }
   else if (touch == self.secondTouch) {
      // we got the second touch
      // do stuff
   }
}

- (void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event {
   if (touch == self.firstTouch) {
      // first touch ended so remove both touches
      self.firstTouch = nil;
      self.secondTouch = nil;
   }
   else if (touch == self.secondTouch) {
      // second touch ended so remove touch only
      self.secondTouch = nil;
   }
}

为了进行触摸检测和存储,我使用了一个教程并对其进行了一些修改,但这让我不知所措:S.我该如何使用UITouch*myTouch=[touch anyObject];CGPoint locationLeft=[myTouch locationInView:[myTouch视图]];locationLeft=[[CCDirector sharedDirector]convertToGL:locationLeft];