我对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];
}
非常感谢您的帮助。
答案 0 :(得分:1)
为什么不在其他地方维护图像数组并使用-subarrayWithRange:NSArray对象的方法来选择要设置动画的图像并将其指定给imageView的animationImages属性。
但我不认为UIImageView为您提供了播放animationImages子阵列的机制。
答案 1 :(得分:1)
我正在编写一个小动画框架来完成这个。您可以在http://github.com/st3fan/iphone-animation
找到代码主要功能包括:
我专门为http://tickletapapps.com集合中的游戏写了这个。它适用于那些游戏中使用的动画类型。如果您需要帮助,请通过Github与我联系。代码正在进行中,但工作得很好。