Suresh Varma
Suresh Varma

Reputation: 9740

detect collision of two moving buttons in iPhone

I am using the below function to move two buttons on the screen

+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished));

Now I want to detect the collision of those moving button.

So I want to know is there any event which is getting fired when the object is animating(moving). Or where else can I place my condition of

CGRectIntersectsRect(,);

Upvotes: 3

Views: 424

Answers (1)

amattn
amattn

Reputation: 10065

+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished));

is a "fire and forget" type animation. You don't have access to the internals. It's automatic.

If you need to do collision detection, you can use a 2D sprite library like Cocos2D or you can set up a timer to move and animate the buttons manually.

Upvotes: 2

Related Questions