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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 06-26-2009, 05:15 PM   #4 (permalink)
smasher
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Then you definitely want to create a Plant class, with a dayCycle method. Then when the sun goes down, you can call this code to to update every plant in the array. Search this board for NSMutableArray if you need help creating the array.
Code:
[plantArray makeObjectsPerformSelector:@selector(dayCycle)];
Inside your plant class, you'll have an "init" method that sets up all of the variables, and the "dayCycle" method that updates all of the variables for this *ONE* plant. dayCycle will look something like this:
Code:
-(void) dayCycle{

     switch (stage) {
		case 0:
			water = 0;
			fertilizer = 0;
			[imageView stopAnimating];
			imageView.frame = CGRectMake(50, frame.center.y-25, 50, 50);
			imageView.animationImages = empty_plot;
			[imageView startAnimating];
			stage = 0;
			break;
		case 1:
//etc...
}
__________________

Free Games!
smasher is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,675
Threads: 89,155
Posts: 380,387
Top Poster: BrianSlick (7,110)
Welcome to our newest member, iTeam4apple
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:55 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.