动画图像Objective-C

动画图像Objective-C,objective-c,graphics,uiimageview,core-animation,Objective C,Graphics,Uiimageview,Core Animation,我正在使用一个动画块来迭代一组.png图像,使其看起来像是一个角色在屏幕上行走。但是,当我缩小图像时,图像的质量会模糊。目前,我正在测试19幅图像的动画,全部分辨率为371 x 379。但是,我需要它们在屏幕上显示得更小,所以我在我的应用程序中将它们缩放到64 x 65。当我这样做的时候,线条会有点扭曲,当我暂停游戏时,你会发现图像质量并没有达到应有的水平。下面是我用来遍历图像的代码。任何帮助都将不胜感激 [UIImageView animaiteWithDuration: 3.0

我正在使用一个动画块来迭代一组.png图像,使其看起来像是一个角色在屏幕上行走。但是,当我缩小图像时,图像的质量会模糊。目前,我正在测试19幅图像的动画,全部分辨率为371 x 379。但是,我需要它们在屏幕上显示得更小,所以我在我的应用程序中将它们缩放到64 x 65。当我这样做的时候,线条会有点扭曲,当我暂停游戏时,你会发现图像质量并没有达到应有的水平。下面是我用来遍历图像的代码。任何帮助都将不胜感激

[UIImageView animaiteWithDuration: 3.0
                            delay: 0
                          options: UIViewAnimationOptionBeginFromCurrentState
                       animations: ^{

 CABasicAnimation *mover = [CABasicAnimation animationWithKeyPath:@"position"];

 // Get the current presentationLayer of the object
 CALayer *currentLayer = self.layer.presentationLayer;

 // Get the current point of the presentationLayer
 CGPoint currentPoint;
 currentPoint.x = currentLayer.position.x;
 currentPoint.y = currentLayer.position.y;

 // Set the new point for the object to move to
 CGPoint newPoint;
 newPoint.x = currentLayer.position.x - 50;
 newPoint.x = currentLayer.position.y;

 // Set the from and to values of the animation
 [mover setFromValue: [NSValue valueWithCGPoint:currentPoint]];
 [mover setToValue: [NSValue valueWithCGPoint:newPoint]];
 [mover setDuration:3.0]; // Set the duration of the mover animation

 // Create the nine-teen UIImages for the array
 UIImage *image1 = [UIImage imageNamed:@"img1"];
 UIImage *image2 = [UIImage imageNamed:@"img2"];
 UIImage *image3 = [UIImage imageNamed:@"img3"];
 UIImage *image4 = [UIImage imageNamed:@"img4"];
 UIImage *image5 = [UIImage imageNamed:@"img5"];
 UIImage *image6 = [UIImage imageNamed:@"img6"];
 UIImage *image7 = [UIImage imageNamed:@"img7"];
 UIImage *image8 = [UIImage imageNamed:@"img8"];
 UIImage *image9 = [UIImage imageNamed:@"img9"];
 UIImage *image10 = [UIImage imageNamed:@"img10"];
 UIImage *image11 = [UIImage imageNamed:@"img11"];
 UIImage *image12 = [UIImage imageNamed:@"img12"];
 UIImage *image13 = [UIImage imageNamed:@"img13"];
 UIImage *image14 = [UIImage imageNamed:@"img14"];
 UIImage *image15 = [UIImage imageNamed:@"img15"];
 UIImage *image16 = [UIImage imageNamed:@"img16"];
 UIImage *image17 = [UIImage imageNamed:@"img17"];
 UIImage *image18 = [UIImage imageNamed:@"img18"];
 UIImage *image19 = [UIImage imageNamed:@"img19"];

 // Populate the animation array
 NSArray *walkingAnimation = [NSArray arrayWithObjects: img1, img2, img3, img4, img5, img6, img7, img8, img9, img10, img11, img12, img13, img14, img15, img16, img17, img18, img19, nil];

 [self setAnimationImages: walkingAnimation]; // Set the animation images to the array
 [self setAnimationRepeatCount:3]; // Repeat the animation every second
 [self setAnimationDuration:1.0]; 

 [self startAnimating]; // Start the animation
 [[self layer] addAnimation:mover forKey:@"position"]; // Add the mover animation to the layer
 [UIImageView commitAnimations];

 [[self layer] setPosition:newPoint]; // Set the position to avoid bounce back

 } completion:nil];

因此,如果有人能告诉我,我是否需要做一些额外的事情来防止图像失真,或者可能是图像本身,我真的可以在阅读Apple API中的所有内容并查看互联网上的每个论坛时使用一些技巧。

你的问题应该与代码无关。您正在将图像调整为不同的纵横比。您应该非常小心调整图像大小,因为图像会自然模糊


您最好的选择是创建精确(清晰)的图像,专门针对您将使用它们的大小而设计。

您的问题应该与代码无关。您正在将图像调整为不同的纵横比。您应该非常小心调整图像大小,因为图像会自然模糊


您最好的选择是创建精确(清晰)的图像,专门针对您将使用它们的大小而设计。

您是在为ios 7开发xcode 5吗?很多事情都变了。我建议您阅读此文档。太棒了。您现在必须创建资产和地图集。这看起来需要做很多工作,但最终会更容易。您是否正在为ios 7开发xcode 5?很多事情都变了。我建议您阅读此文档。太棒了。您现在必须创建资产和地图集。这看起来需要做很多工作,但最终它会变得更容易