GJH385
GJH385

Reputation: 25

How to stop collision when hidden

I'm aware that this question has been asked before, but there was no answer.

I have objects which are linked with the player using the following code:

if (CGRectIntersectsRect(Player.frame, obstacle.frame)) {
    [self finish];
    // later on in the code i then hide the obstacle

    obstacle.hidden = YES;
}

but when the object is hidden it still detects a collision is there away to remove collision when the object is hidden ?

Upvotes: 0

Views: 39

Answers (1)

Philip
Philip

Reputation: 1078

You probably have to provide more Information but why don't you check whether the obstacle is hidden before you execute the collision-code?

if (obstacle.hidden != YES) {
  // collision-code
}

Upvotes: 1

Related Questions