简体   繁体   中英

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(,);
+ (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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM