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 Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-09-2008, 11:59 AM   #1 (permalink)
Registered Member
 
roberthuttinger's Avatar
 
Join Date: Sep 2008
Posts: 96
roberthuttinger is on a distinguished road
Default Coin Flip Animation?

I wrote some code for flipping a coin and I used 24 images to simulate the coin flipping 2 times then it shows a coin. heres the problem, I use a timer to call the updated image at an interval of 0.01 but the pp kept crashing at random times. I removed the 'animation' and now it seems stable.

is there a way to animate the coinflip that is jesusPhone friendly?

cheers.rob
roberthuttinger is offline   Reply With Quote
Old 09-09-2008, 12:48 PM   #2 (permalink)
mr.
 
refreshe's Avatar
 
Join Date: Jul 2008
Location: SF, California | Melbourne, Australia
Posts: 346
refreshe is on a distinguished road
Default

Put the images into an array, then have your UIImageView animate the array. It has functionality for that. You can set the animation duration etc.
Or is that what you already did and it was crashing?
__________________
appz
refreshe is offline   Reply With Quote
Old 09-09-2008, 12:55 PM   #3 (permalink)
Registered Member
 
roberthuttinger's Avatar
 
Join Date: Sep 2008
Posts: 96
roberthuttinger is on a distinguished road
Default

put the images into an array, thanks Ill look around for that. Ive found tutorial on animations but they were variations on what I needed. any exmples you can thik of?

cheers.rob
roberthuttinger is offline   Reply With Quote
Old 09-09-2008, 01:18 PM   #4 (permalink)
mr.
 
refreshe's Avatar
 
Join Date: Jul 2008
Location: SF, California | Melbourne, Australia
Posts: 346
refreshe is on a distinguished road
Default

just off the top, i think it'd look something like this. you'll have to test it though :P

coin1, coin2, coin3 are UIImages.

Code:
       coin1 = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"coin1" ofType:@"png"]];
       coin2 = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"coin2" ofType:@"png"]];
       coin3 = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"coin3" ofType:@"png"]];

	coinImageArray = [NSArray arrayWithObjects:coin1, coin2, coin3, nil];
	
	[coin1 release];
	[coin2 release];
	[coin3 release];

	[coinImageView setAnimationImages:coinImageArray];
	[coinImageView setAnimationRepeatCount:1];	//0 for looping
	[coinImageView setAnimationDuration:1.0];	//how long 1 cycle of animation lasts


       [coinImageView startAnimating];    // also stopAnimating
__________________
appz

Last edited by refreshe; 09-09-2008 at 01:35 PM.
refreshe is offline   Reply With Quote
Old 09-09-2008, 01:26 PM   #5 (permalink)
Registered Member
 
roberthuttinger's Avatar
 
Join Date: Sep 2008
Posts: 96
roberthuttinger is on a distinguished road
Default

cheers ill try it and just for those who also see this, the top of the code was truncated:
coin1 = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"coin1" ofType:@"png"]];
coin2 = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"coin2" ofType:@"png"]];
coin3 = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"coin3" ofType:@"png"]];


cheers.rob
roberthuttinger is offline   Reply With Quote
Old 09-09-2008, 01:35 PM   #6 (permalink)
mr.
 
refreshe's Avatar
 
Join Date: Jul 2008
Location: SF, California | Melbourne, Australia
Posts: 346
refreshe is on a distinguished road
Default

cool, hope it works for you.
damn that code got chopped. i edited it back in.
__________________
appz
refreshe is offline   Reply With Quote
Reply

Bookmarks

Tags
animation, coin, flip, images, timer

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: 327
13 members and 314 guests
akacaj, alexP, ClerurcifeDer, Duncan C, givensur, GraffitiCircus, guusleijsten, JmayLive, NetGuru, Paul Slocum, Punkjumper, Sloshmonster, yys
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,883
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

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