Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 06-26-2009, 04: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: 2,575
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...
}
__________________
smasher is online now   Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,261
Threads: 39,058
Posts: 171,277
Top Poster: smasher (2,575)
Welcome to our newest member, SomeRandomNerd
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:37 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.