Если вызывается функция ccTouchesMoved, спрайты, находящиеся в области движущегося пальца, должны быть добавлены в массив.Но только ОДИН РАЗ.Я получаю результат, что он добавляет спрайт несколько раз (потому что палец все еще на спрайте, когда он перемещается к внешней стороне спрайта).Поэтому я инкапсулировал его в оператор if, которого следует избегать.Но это не ... Что мне делать?
-(void) ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *myTouch = [touches anyObject];
CGPoint location = [myTouch locationInView:[myTouch view]];
CGPoint convertedLocation = [[CCDirector sharedDirector] convertToGL:location];
CCSprite* realSprite = [self whichHexagonTouched:convertedLocation];
NSNumber *hexTag = [NSNumber numberWithInt:realSprite.tag];
// If the hexagon is not in the array and not nil, it should destroy it and add it to the array
if(realSprite != nil && ![hexTags containsObject:hexTag]){
[self destroyHexagon:realSprite];
[hexTags addObject:hexTag];
NSLog(@"these are the hexTags %@", hexTags);
}
}