0

我正在尝试设置一个动画,其中一个球有一个速度,并被加速到接触点。首先,我从http://www.youtube.com/watch?v=buFCoj2jqDk&feature=relmfu的教程中成功转录了一个应用程序。

但是当我试图引入速度的概念时,我似乎在矢量数学上失败了。我想简单地把两个向量相减,但直到我进入下面的详细选项,我才得到正确的语法。

该应用程序提供了“断点 1.1”

相关代码如下:

@interface ViewController : UIViewController {UIImageView *spritey; CGPoint vee; CGPoint acc;}
@property (nonatomic, retain) UIImageView *spritey;
@property (assign) CGPoint vee;
@property (assign) CGPoint acc;
@end

//.m
- (void)viewDidLoad
{
[super viewDidLoad];
spritey = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"cloud2.png"]];
[spritey setFrame:CGRectMake(60,60,50,50)];
[self.view addSubview:spritey];
vee=CGPointMake(0,0);
}
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    UITouch *myTouch=[ touches anyObject];
    [UIView beginAnimations:@"moveTo" context:NULL];
    [UIView setAnimationDuration: 2.25];
    [UIView setAnimationBeginsFromCurrentState:YES];
    CGPoint newTarget=[myTouch locationInView:self.view];
    vee=CGPointMake(vee.x+(newTarget.x-spritey.center.x)/10,
                    vee.y+(newTarget.y-spritey.center.y)/10);
   spritey.center=CGPointMake(spritey.center.x+vee.x,spritey.center.y+vee.y);
   //spritey.center=[myTouch locationInView:self.view];
   [UIView setAnimationDelegate:self];
   [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
   [UIView commitAnimations];
4

1 回答 1

0

在断点处停止是一个调试工具,而不是错误,据我们这里的朋友说: “Thread 1: stopped at breakpoint” error when initializing an NSURL object

不知何故,我一定打开了一个。Going to View--> Navigator --> Show Breakpoint Navigator 把我带到了一个我可以删除它的地方。

代码现在按预期工作!

于 2012-10-10T01:41:03.280 回答