Guest User

Untitled

a guest
Aug 10th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. ccTouchesMoved adds object to array multiple times, even though an if statement should avoid that
  2. -(void) ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
  3. {
  4. UITouch *myTouch = [touches anyObject];
  5. CGPoint location = [myTouch locationInView:[myTouch view]];
  6. CGPoint convertedLocation = [[CCDirector sharedDirector] convertToGL:location];
  7.  
  8. CCSprite* realSprite = [self whichHexagonTouched:convertedLocation];
  9.  
  10. NSNumber *hexTag = [NSNumber numberWithInt:realSprite.tag];
  11.  
  12. // If the hexagon is not in the array and not nil, it should destroy it and add it to the array
  13.  
  14. if(realSprite != nil && ![hexTags containsObject:hexTag]){
  15. [self destroyHexagon:realSprite];
  16. [hexTags addObject:hexTag];
  17.  
  18. NSLog(@"these are the hexTags %@", hexTags);
  19. }
  20.  
  21.  
  22. }
Add Comment
Please, Sign In to add comment