检测的iPhone两个移动按钮碰撞 [英] detect collision of two moving buttons in iPhone

查看:164
本文介绍了检测的iPhone两个移动按钮碰撞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的函数来移动屏幕上的两个按钮

  +(无效)animateWithDuration:(NSTimeInterval)工期延误:(NSTimeInterval)延时选项:(UIViewAnimationOptions)选项动画:(无效(^)(无效))的动画完成:(无效(^)(BOOL完));

现在我要检测这些移动按钮的碰撞。

所以,我想知道的是有对象时动画(移动),这是被解雇的任何事件。
或者,我还有什么地方可以把我的状态

  CGRectIntersectsRect(,);


解决方案

  +(无效)animateWithDuration:(NSTimeInterval)工期延误:(NSTimeInterval)延时选项:(UIViewAnimationOptions)选项动画: (无效(^)(无效))动画完成:(无效(^)(BOOL完));

是射后不理式的动画。您不必访问该内部。这是自动的。

如果你需要做的碰撞检测,你可以用一个2D精灵库一样的Cocos2D或者你可以设置一个计时器,移动和手动动画按钮。

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.

这篇关于检测的iPhone两个移动按钮碰撞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆