cocos2d multi object touch administration
I'm programming a game, where you can click many objects like point and click. Current I receive the touch-events on an CCLayer and iterate over all objects to find out the touched object.
for (GameObjectSprite *object in objects) {
if ([object isTouchOnMe:touch]) {
NSLog(@"Touch Beegan Objekt:%@", object.dataModel.name);
}
}
Edite:开发者_JAVA技巧
- (BOOL) isTouchOnMe: (CGPoint) touchLocation {
return = CGRectContainsPoint([animationSprite boundingBox], touchLocation);
}
Is there a better solution to find out the touched object, e.g. every object throws an event when it is touched?
精彩评论