r/simpleios • u/JDandCokeaine • Jul 20 '12
[Question] UIImageView.animationImages
Hi Guys,
There are a few half answers to my question online. But I can't get the ideal solution so I would like to discuss it.
I am creating a coin toss animation app. I tried to implement it with Open GL but found it difficult to incorporate the third dimension of the coin. So for Plan B I have built the filps using UIImageView.animationImages.
I have 4 animations HH HT TH and TT.
I am loading the images in with :
headsTails =[[NSArray alloc] initWithObjects: [UIImage imageNamed:@"Frame 1ht.png"], // 0 [UIImage imageNamed:@"Frame 2ht.png"],
. . . . (etc ) . . . . . . . . . [UIImage imageNamed:@"Frame 90ht.png"], nil ];
The performance is terrible. ( As I expected it to be) I currently takes 6 seconds to load in the image arrays.
What do you suggest?
Thanks!
3
u/SeanMoney Jul 20 '12
Try making a sprite sheet. I do it all the time with Cocos2d, but haven't done it with UIKit, but it seems like it's not too hard. Stack Overflow link
3
u/mkim1030 Jul 21 '12 edited Jul 21 '12
If its a really simple flip animation ("head" side to "tails" side flip), you could try using a uiview animation (syntax might be off since i'm typing from my phone):
You only need 2 images for this animation. Hope that helps.
2
u/cubedgame Jul 21 '12
Are you really typing all 90 images in by hand like that? That would be painful! I use the same UIImageView animation technique in one of the apps I'm building, but don't notice any delay when launching the app. I use only 30 images and they of a pretty small resolution though so that could be a reason it's so quick for me.
Here's how I initialize my ImageView's animationImages. It might not help you any, but it could be worth a shot:
Edit: Forgot to copy/paste a couple of lines at the end.