/ / मल्टी टच को सक्षम करना ... 2 के टच को स्टोर करने में मदद की जरूरत है - कोको-टच, कोको 2 डी-आईफोन, टच

मल्टी टच सक्षम करना ... दूसरे स्पर्श को संग्रहित करने में मदद की ज़रूरत है - कोको-टच, कोकोस 2 डी-आईफोन, स्पर्श करें

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];

मैं दूसरा स्पर्श कैसे स्टोर कर पाऊंगा?

अग्रिम में धन्यवाद

उत्तर:

जवाब के लिए 2 № 1

आपको उपयोग करना चाहिए ccTouchBegan ("स्पर्श" के बजाय एकवचन "स्पर्श" पर ध्यान दें) जब आपको बहु-स्पर्श को संभालने की आवश्यकता होती है। (IMO के लोगों को ccTouchesBegan / Moved / Ended को बस खोदना चाहिए और ccTouchBegan / Moved / Ended का उपयोग करना चाहिए)

CcTouchBegan / Moved / Ended में से प्रत्येक को प्रत्येक स्पर्श के लिए कहा जाता है जिसका अर्थ है कि आप आसानी से कई स्पर्शों में अंतर कर सकते हैं। उदाहरण:

- (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;
}
}

जवाब के लिए 0 № 2

क्या आपने इस तरह के स्पर्श के माध्यम से पुनरावृति की कोशिश की है?

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