在ios7中使用核心图形连续设置uiview动画

在ios7中使用核心图形连续设置uiview动画,ios,iphone,ios7,uiview,core-graphics,Ios,Iphone,Ios7,Uiview,Core Graphics,我正在创建一个类似于bubble shooter的游戏,其中uiview对象将根据触摸屏幕的位置连续设置动画。我可以根据触摸事件设置uiview对象的动画,但问题是,它会在我单击的触摸点处停止。我使用uiview动画,在那里我会给1秒钟的时间设置球的动画。但我不想让球停在那个点上,让它自动转到我单击的前进方向,它还应该注意屏幕大小,使球(UIView)不会消失。这是我的代码 -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)eve

我正在创建一个类似于bubble shooter的游戏,其中uiview对象将根据触摸屏幕的位置连续设置动画。我可以根据触摸事件设置uiview对象的动画,但问题是,它会在我单击的触摸点处停止。我使用uiview动画,在那里我会给1秒钟的时间设置球的动画。但我不想让球停在那个点上,让它自动转到我单击的前进方向,它还应该注意屏幕大小,使球(UIView)不会消失。这是我的代码

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
 gameTimer = [CADisplayLink displayLinkWithTarget:self selector:@selector(updateDisplay:)];
 [gameTimer addToRunLoop:[NSRunLoop currentRunLoop]forMode:NSDefaultRunLoopMode];
}
-(void) updateDisplay:(CADisplayLink*)sender
{


                        if (lastTime == 0.0)
                        {
                           // First time through, initialize the lastTime
                             lastTime = previousTimeStampValue;


                         }
                         else
                         {

                             timeDelta = sender.timestamp - lastTime; // Update the lastTime
                             lastTime = sender.timestamp;


                             ballRect.origin.x += ballVelocity.x * timeDelta;
                             ballRect.origin.y += ballVelocity.y * timeDelta;

                             [self checkCollisionWithScreenEdges];
                        }

                   [currentBallView setFrame:ballRect];


                  // currentBallView.center = ballRect.origin;



}

你的速度计算可能有点错误,但我不能说,因为你没有显示代码。再说一次,当你可以使用精灵工具包时,我不建议你使用核心图形。我使用速度(200,-200)来移动我的对象。