English 中文(简体)
如何在估测时发现两个图像框架的交叉部分?
原标题:How to detect intersect of two image frames while animating?

我在《问讯》中发表了一份名为targetView的“UIImage”的书,其中我写了以下几句:

[UIView animateWithDuration:1.0
                 animations:^{self.targetView.center = CGPointMake(220,20);}
                 completion:^(BOOL finished){
                                             //another animation will begin;
                                            }];

我还创建了另一个叫做的UIImageView,该意见将在inger子上朝目标方向迈进。 其运动也作为一种动画实施。 在计算结果结束时,发现与目标意见的交叉部分:

[UIView animateWithDuration:1.0
                 animations:^{
                 self.shootView.center = CGPointMake(destX, destY);}
                 completion:^(BOOL finished){
                            if (CGRectIntersectsRect(self.targetView.frame, self.shootView.frame)) {
                            //do something
                             }];

现在存在一个问题:如果目标意见达到目前的估计点,而且枪口会发生的话,教派的指挥只能进行罚款。 具体目标 一种看法是,在估计的中间点,即使从表面上看两个框架相互交错,也不可能发现任何sect。

最佳回答

这种做法可能很trick,因为你只能在《国际律师联合会意见》的开始和结束时得到反馈。 举例来说,CGRectIntersectionRect 方法只是在 an灭之后才采用。

一种解决办法是,利用一架安保时光仪来清理枪道的位置,每次改变位置,都会发现碰撞。 i.e

[NSTimer timerWithTimeInterval: 0.03 target: self selector: @selector(timerTicked:) userInfo: nil repeats: YES];

-(void) timerTicked: (NSTimer*) timer {

  // do move
  // check for colisions
  // optional invalidation of timer
}
问题回答

暂无回答




相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签