我有个关于png动画序列的问题。
我正在将图片从1-35加载到一个图层中,并使用- initWithImage
初始化第一个图像。我有几个按钮,希望能够播放图像序列数组的不同范围。
有没有办法只播放1-10的图像?
有没有办法控制播放的图像范围..。11 - 35或4- 20什么的?
当然,我尝试用不同的图像数组创建单独的层,并将这些层放在另一个之上。他们的问题是initWithImage
。如果我播放第二层,我可以看到下面的初始化图像。
这是我的图像序列代码:
- (void) loadAnim05 {
cAnim = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cof_01.png"]];
cAnim.center = CGPointMake(78,211);
NSMutableArray *array = [NSMutableArray array];
for (int i = 1; i <= 35; i++)
[array addObject:[UIImage imageNamed:[NSString stringWithFormat:@"cof_%02d.png",i]]];
cAnim.animationImages = array;
cAnim.animationDuration = 1.0;
cAnim.animationRepeatCount = 1;
[self.view addSubview:cAnim];
[cAnim release];
}
非常感谢您的帮助。
发布于 2010-02-05 16:39:04
为什么不在其他地方维护一个图像数组,并使用-subarrayWithRange: NSArray对象的方法来选择要动画的图像,并将其分配给imageView的animationImages属性。
但我不认为UIImageView为您提供了播放animationImages子数组的机制。
发布于 2010-02-05 20:24:24
我正在编写一个小小的动画框架来做到这一点。您可以在http://github.com/st3fan/iphone-animation找到代码
主要特点是:
针对普通background
导出的)转换为简单的单文件容器格式,
。
我专门为http://tickletapapps.com集合中的游戏编写这篇文章。它对那些游戏中使用的动画效果很好。如果您需要帮助,请通过Github与我联系。这段代码正在进行中,但运行得很好。
https://stackoverflow.com/questions/2211416
复制相似问题