开发者

cocos2d multi object touch administration

开发者 https://www.devze.com 2023-03-04 12:48 出处:网络
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.

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

精彩评论

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

关注公众号