0
由于下面的代码(代码位于ViewController.h文件的viewDidLoad:方法中),我正在执行一个迷宫教程(link),其中我为名为ghost1的UIImageView设置了动画:CABasicAnimation在暂停后不起作用
CGPoint origin1 = self.ghost1.center;
CGPoint target1 = CGPointMake(self.ghost1.center.x, self.ghost1.center.y-124);
CABasicAnimation *bounce1 = [CABasicAnimation
animationWithKeyPath:@"position.y"];
bounce1.fromValue = [NSNumber numberWithInt:origin1.y];
bounce1.toValue = [NSNumber numberWithInt:target1.y];
bounce1.duration = 2;
bounce1.autoreverses = YES;
bounce1.repeatCount = HUGE_VALF;
[self.ghost1.layer addAnimation:bounce1 forKey:@"position"];
在这一点上,它运作良好。现在,我想为应用程序添加一个新的初始视图(以便首先显示菜单而不是直接显示游戏),并在此新视图中按下“开始”按钮时启动游戏。
我添加了按钮和“show”类型的segue。当我按下按钮, 游戏显示,但动画不起作用。
你知道为什么以及如何纠正吗?