Code:
switch (plant1stage) {
case 0:
plant1water = 0;
plant1fertilizer = 0;
[plant1 stopAnimating];
plant1.frame = CGRectMake(50, plant1.center.y-25, 50, 50);
plant1.animationImages = empty_plot;
[plant1 startAnimating];
plant1stage = 0;
break;
case 1:
if (plant1fertilizer >= required_fert_tree) {
if (plant1water >= required_water_tree) {
plant1water = 0;
plant1fertilizer = 0;
[plant1 stopAnimating];
plant1.frame = CGRectMake(50, plant1.center.y-160, 320, 350);
plant1.animationImages = apple_stage_1;
[plant1 startAnimating];
plant1stage = 2;
} else {
[plant1 stopAnimating];
plant1.frame = CGRectMake(50, plant1.center.y-25, 50, 50);
plant1.animationImages = empty_plot;
[plant1 startAnimating];
plant1stage = 0;
}
} else {
[plant1 stopAnimating];
plant1.frame = CGRectMake(50, plant1.center.y-25, 50, 50);
plant1.animationImages = empty_plot;
[plant1 startAnimating];
plant1stage = 0;
}
break;
case 2:
Thats the gist of my code, there are a total of 12 plants, each one has its one Water, Fertilizer, stage and image. The switch is designed to be the end of a day cycle that causes the plants to grow. They grow only if they have enough water and fertilizer.