detect collision of two moving buttons in iPhone

2020-07-18 11:35发布

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

1条回答
该账号已被封号
2楼-- · 2020-07-18 11:57
+ (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.

查看更多
登录 后发表回答