I have not posted to the game section before. I have never created a game but I am looking into it for the purpose of add features to my other products.
I am starting off with something I would consider fairly simple, but I came unstuck pretty darn quickly.
This is a conceptual question.
I have an animation that runs for about 10 seconds. During the game loop, the animation is repeated, back and forth. It doesn't play beginning to end though. Depending on user input, it will play forward and then they may change and play it backwards. This change in direction happens pretty quickly.
My question is, how do I integrate the animation into my code? I really have no idea!!
Do I turn the animation into an image sequence, store the images in an array and traverse the array forward or backwards depending on user input?
Do I play the animation as a movie and just play it forwards or backwards depending on user input?
Am I thinking about this in completely the wrong way?
I have not posted to the game section before. I have never created a game but I am looking into it for the purpose of add features to my other products.
I am starting off with something I would consider fairly simple, but I came unstuck pretty darn quickly.
This is a conceptual question.
I have an animation that runs for about 10 seconds. During the game loop, the animation is repeated, back and forth. It doesn't play beginning to end though. Depending on user input, it will play forward and then they may change and play it backwards. This change in direction happens pretty quickly.
My question is, how do I integrate the animation into my code? I really have no idea!!
Do I turn the animation into an image sequence, store the images in an array and traverse the array forward or backwards depending on user input?
Do I play the animation as a movie and just play it forwards or backwards depending on user input?
Am I thinking about this in completely the wrong way?
or you can do it the quick and dirty way (the way i prefer) and just step through them with a switch/case block. That's of course only if you are cycling through images, I used this to great effect for exploding missiles and such. it takes a little less time and resources to do it this way i believe. Below I was running 60 f/s so I gave 2 frames per pic as I stepped up j each loop so it's visible.
- (void)blowupStart {
switch (j) {
case 1:
[self.blowup setImage:[UIImage imageNamed:@"blowup1.png"]];
break;
case 3:
[self.blowup setImage:[UIImage imageNamed:@"blowup2.png"]];
break;
case 5:
[self.blowup setImage:[UIImage imageNamed:@"blowup3.png"]];
break;
case 7:
[self.blowup setImage:[UIImage imageNamed:@"blowup4.png"]];
break;
case 9:
[self.blowup setImage:[UIImage imageNamed:@"blowup5.png"]];
break;
case 11:
j=0;
break;
}
}
UIKit is terribly inefficient for game programming. Look up cocos2d or if you're really daring, OpenGL ES programming tutorials. What you want is for IOS to start up, give you a view, then get out of your way so you can do the basic game event loop and define how things are drawn yourself.
UIKit is terribly inefficient for game programming. Look up cocos2d or if you're really daring, OpenGL ES programming tutorials. What you want is for IOS to start up, give you a view, then get out of your way so you can do the basic game event loop and define how things are drawn yourself.
Wow, how much experience do you have with UIKit? It's actually extremely efficient and a miser when it comes to memory consumption and function call time. The only problem with it (like assembly) is that you have to write a lot more code then GLES and cocos2d (or even sparrow).
I will be looking at cocos2d in the future, but for this project I want to work with something more familiar, so UIKit it is.
The suggestions above look good and I will give them a go.
I believe I will have to use a switch case statement.
Basically, I will have my array of say 50 images. The animation may go from 1 to 10 then the user sends it back from 10 to 5, then back again from 5 to 25.
Not sure how I am going to tackle this...
Perhaps have my main array of 50 images, then create a sub array which is to be animated using .animationImages
Ok, so I have used the startAnimating example above to get my animations to work.
Things are looking pretty good with one exception.
I only want to animation to play through once, and I got that working.
The problem is, when the animation stops it automatically goes back to the first frame. I want it to end up at the last frame. Is there any way to do this?