开发者

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜