Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-06-2011, 01:47 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 249
gabacus is on a distinguished road
Default This is my first time, so be gentle...

Hi Guys,

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?

Any help would be greatly appreciated.

Cheers
__________________
-- Website --
SpartanApps

-- Current Apps --
Musicopoulos
gabacus is offline   Reply With Quote
Old 02-06-2011, 03:11 AM   #2 (permalink)
Dr. Gerbil
 
1337Skittles's Avatar
 
Join Date: Aug 2010
Location: Kentucky
Posts: 129
1337Skittles is on a distinguished road
Default

Quote:
Originally Posted by gabacus View Post
Hi Guys,

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?

Any help would be greatly appreciated.

Cheers
try this for animating a series of images:

Code:
NSArray *myImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"myImage1.png"], 
[UIImage imageNamed:@"myImage2.png"], 
[UIImage imageNamed:@"myImage3.png"], 
[UIImage imageNamed:@"myImage4.gif"], nil]; 
UIImageView *myAnimatedView = [UIImageView alloc];
 [myAnimatedView initWithFrame:[self bounds]];
 myAnimatedView.animationImages = myImages;
 myAnimatedView.animationDuration = 0.25; // seconds
 myAnimatedView.animationRepeatCount = 0; // 0 = loops forever
 [myAnimatedView startAnimating];
 [self addSubview:myAnimatedView]; 
[myAnimatedView release];
1337Skittles is offline   Reply With Quote
Old 02-06-2011, 04:22 AM   #3 (permalink)
Registered Member
 
missing_no's Avatar
 
Join Date: Feb 2011
Posts: 41
missing_no is on a distinguished road
Default

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;
}
}
missing_no is offline   Reply With Quote
Old 02-06-2011, 02:54 PM   #4 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 226
mlfarrell is on a distinguished road
Default

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.
__________________


http://vertostudio.com/
mlfarrell is offline   Reply With Quote
Old 02-07-2011, 03:09 PM   #5 (permalink)
Registered Member
 
missing_no's Avatar
 
Join Date: Feb 2011
Posts: 41
missing_no is on a distinguished road
Default

Quote:
Originally Posted by mlfarrell View Post
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).
missing_no is offline   Reply With Quote
Old 02-07-2011, 04:48 PM   #6 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 249
gabacus is on a distinguished road
Default

Thanks for the feedback guys.

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

Hmm... there is a bit of work to be done
__________________
-- Website --
SpartanApps

-- Current Apps --
Musicopoulos
gabacus is offline   Reply With Quote
Old 02-08-2011, 07:51 PM   #7 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 249
gabacus is on a distinguished road
Default

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?
__________________
-- Website --
SpartanApps

-- Current Apps --
Musicopoulos
gabacus is offline   Reply With Quote
Old 02-09-2011, 04:19 PM   #8 (permalink)
Registered Member
 
god0fgod's Avatar
 
Join Date: Jul 2010
Posts: 278
god0fgod is on a distinguished road
Default

Core animation and other quartz APIs will be accelerated with the graphics processor wont they? So it should be fast?
__________________
god0fgod is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 419
9 members and 410 guests
7twenty7, chemistry, ChrisYates, hussain1982, Retouchable, skrew88, SLIC, walex, xzoonxoom
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,128
Posts: 402,921
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:10 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0