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-27-2009, 02:23 AM   #5 (permalink)
ataranlen
Registered Member
 
ataranlen's Avatar
 
Join Date: Jun 2009
Location: Flower Mound, Texas
Age: 22
Posts: 66
Default

Alright, I am having alot of issues with creating my own class called StageClass. Do you know of any tutorial on how to create a custom class? Every google search turns up junk about how the iphone is world class ect. I'll keep looking though.

Edit: So I finally found some tutorials, and here's what I'm up to:

The only problem is, I can't get the image to show up at all.

Code:
//
//  StageClass.h
//

#import <Foundation/Foundation.h>

@interface StageClass : NSObject
{
	// Initialization of the properties
	int plantState;
	int water;
	int harvest;
	int harvestCounter;
	int fertilizer;
	UIImageView *imageView;
	
}

@property(assign, readwrite) int plantState;
@property(assign, readwrite) int water;
@property(assign, readwrite) int harvest;
@property(assign, readwrite) int harvestCounter;
@property(assign, readwrite) int fertilizer;
@property(retain, readwrite) UIImageView *imageView;


@end
Code:
//  StageClass.m

#import "StageClass.h"

@implementation StageClass
@synthesize plantState = _plantState;
@synthesize water = _water;
@synthesize fertilizer = _fertilizer;
@synthesize harvest = _harvest;
@synthesize harvestCounter = _harvestCounter;
@synthesize imageView = _imageView;

- (void)endDayCycle{
	switch (plantState) {
		case 0:
			water = 0;
			fertilizer = 0;
			[imageView stopAnimating];
			imageView.userInteractionEnabled = YES;
			imageView.frame = CGRectMake(50, 430, 320, 350);
			imageView.animationImages = [[NSArray alloc] initWithObjects:    
										 [UIImage imageNamed:@"empty_plot_filler.png"],nil] ;
			[imageView startAnimating];
			
			plantState = 0;
			break;
		case 1:
			if (fertilizer >= 3) {
				if (water >= 3) {
					water = 0;
					fertilizer = 0;
					[imageView stopAnimating];
					imageView.animationImages = [[NSArray alloc] initWithObjects:    
												 [UIImage imageNamed:@"001.png"],
												 [UIImage imageNamed:@"001.png"],nil] ;;
					[imageView startAnimating];
					plantState = 2;
				} else {
					[imageView stopAnimating];
					imageView.animationImages = [[NSArray alloc] initWithObjects:    
												 [UIImage imageNamed:@"empty_plot_filler.png"],nil] ;;
					[imageView startAnimating];
					plantState = 0;
				}
			} else {
				[imageView stopAnimating];
				imageView.animationImages = [[NSArray alloc] initWithObjects:    
											 [UIImage imageNamed:@"empty_plot_filler.png"],nil] ;;
				[imageView startAnimating];
				plantState = 0;
			}
			break;
			
	}
}
-(void) dealloc
{
	[imageView release];
	[super dealloc];
}

@end
Code:
//exerpt from ViewController.h:
IBOutlet StageClass *plant1;
}
@property(nonatomic,retain) StageClass *plant1;
Code:
//exerpt from -(void)viewdidload from ViewController.m:
	plant1.imageView = [[UIImageView alloc] initWithFrame:self.view.frame];
	plant1.imageView.userInteractionEnabled = YES;
	plant1.imageView.frame = CGRectMake(50, 0, 320, 350);
	plant1.imageView.animationImages = empty_plot;
	plant1.imageView.animationDuration = 0.5;
	plant1.imageView.animationRepeatCount = 0;
	[plant1.imageView startAnimating];

Last edited by ataranlen; 06-27-2009 at 03:54 AM.
ataranlen is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,835
Threads: 89,209
Posts: 380,642
Top Poster: BrianSlick (7,129)
Welcome to our newest member, Aubrey69
Powered by vBadvanced CMPS v3.1.0

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