Sean
Sean

Reputation: 21

How to check boundary of a sprite when another sprite is moving? (Cocos2D)

I want to detect the boundary of a sprite when another sprite is moving to prevent the same position of sprites. How to do it? Any help....

Upvotes: 0

Views: 128

Answers (1)

Rajneesh071
Rajneesh071

Reputation: 31081

You can schedule method to check position in init method

[self schedule:@selector(update:)];  

and then

- (void)update:(ccTime)dt {

    if (CGRectIntersectsRect(sprite1.boundingBox, sprite2.boundingBox)) {
     //do what ever you want    
    }
}

Upvotes: 1

Related Questions