创建图像后的动画问题
大家好,这里是我的代码:
-(void) onTimer {
UIImage * image = [UIImage imageNamed:@"abouffer_03.png"];
imageView = [[UIImageView alloc] initWithImage:image];
[imageView setCenter:[self randomPointSquare]];
[[self view] addSubview:imageView];
ix=imageView.center.x;
iy=imageView.center.y;
X=(240-ix)/230;
Y=(160-iy)/230;
}
-(void)onTimer2{
imageView.center = CGPointMake(imageView.center.x + X, imageView.center.y + Y);
}
“onTimer”每 4 秒调用一次,并且“onTimer2”上有一个 CADisplayLink (60fps)。
我的问题是每次调用“onTimer”时“imageView”的动画都会停止;创建一个新的“imageView”,然后 imageView 使用“onTimer2”方法移动,然后停止并创建另一个“imageView”...
我想要的是“imageView”的动画继续并同时创建新的“imageView” ,请问我该怎么做?抱歉我的英语我是法国人:/
Hi every one here is my code :
-(void) onTimer {
UIImage * image = [UIImage imageNamed:@"abouffer_03.png"];
imageView = [[UIImageView alloc] initWithImage:image];
[imageView setCenter:[self randomPointSquare]];
[[self view] addSubview:imageView];
ix=imageView.center.x;
iy=imageView.center.y;
X=(240-ix)/230;
Y=(160-iy)/230;
}
-(void)onTimer2{
imageView.center = CGPointMake(imageView.center.x + X, imageView.center.y + Y);
}
"onTimer" is called every 4 seconds and there is a CADisplayLink (60fps) on "onTimer2".
My problem is that "imageView"'s animation stops every time "onTimer" is called; a new "imageView" is created then imageView move with "onTimer2" method then it stops and another "imageView" is created ...
What I want is that "imageView"'s animation continues and in parallel new "imageView"s are created, how can I do this please ? sorry for my english I'm french :/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您每次都使用相同的 imageView 对象来分配和初始化。您需要使用不同的
imageView
,例如:You are using same
imageView
object to alloc and initialize every time. You need to use differentimageView
, like: