PDA

View Full Version : I need help with XCODE




TonyTokyo
May 14, 2011, 09:31 PM
I need help with tis code I m getting error message,

here is the error message.

code here

[NSTimer scheduledTimerWithTimeInterval:1.0/60 target:self selector:@selector(gameloop) userinfo:nil repeats:YES];

with error message- NSTimer may not respond to '+scheduledTimerWithTimeInterval:target:selector:userinfo:repeat:'


Here is the whole code that I was working on
cheers





#import "gameViewController.h"



#define kStateRunning 1

#define kStateGameOver 2



#define kGravity 0.195



@implementation gameViewController

@synthesize bg, ball, platform1, platform2, platform3, platform4, platform5;

@synthesize gameState;

@synthesize ballVelocity, gravity;



//Implement viewDidLoad to do additional setup after loading the view,typically from a nib.

- (void)viewDidLoad {

[super viewDidLoad];

gameState = kStateRunning;

ballVelocity = CGPointMake(0, 0);

gravity =CGPointMake(0, kGravity);



[NSTimer scheduledTimerWithTimeInterval:1.0/60 target:self selector:@selector(gameloop) userinfo:nil repeats:YES];

}



- (void)gameloop {

if (gameState == kStateRunning)

{

[self gameStatePlayNormal];

}

else if (gameState == kStateGameOver)

{



}

}



- (void)gameStatePlayNormal {

ballVelocity.y += gravity.y;



ball.center = CGPointMake(ball.center.x + ballVelocity.x,ball.center.y + ballVelocity.y);

}



/*

// The designated initializer. Override to perform setup that is required before the view is loaded.

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

if (self) {

// Custom initialization

}

return self;

}

*/



/*

// Implement loadView to create a view hierarchy programmatically, without using a nib.

- (void)loadView {

}

*/





/*

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.

- (void)viewDidLoad {

[super viewDidLoad];

}

*/





/*

// Override to allow orientations other than the default portrait orientation.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

// Return YES for supported orientations

return (interfaceOrientation == UIInterfaceOrientationPortrait);

}

*/



;- (void)didReceiveMemoryWarning {

// Releases the view if it doesn't have a superview.

[super didReceiveMemoryWarning];



// Release any cached data, images, etc that aren't in use.

}



- (void)viewDidUnload {

// Release any retained subviews of the main view.

// e.g. self.myOutlet = nil;

self.bg = nil;

self.ball = nil;

self.platform1 = nil;

self.platform2 = nil;

self.platform3 = nil;

self.platform4 = nil;

self.platform5 = nil;

}





- (void)dealloc {

[super dealloc];

[bg release];

[ball release];

[platform1 release];

[platform2 release];

[platform3 release];

[platform4 release];

[platform5 release];

}

@end



gnasher729
May 15, 2011, 03:18 AM
I need help with tis code I m getting error message,

here is the error message.

code here

[NSTimer scheduledTimerWithTimeInterval:1.0/60 target:self selector:@selector(gameloop) userinfo:nil repeats:YES];

with error message- NSTimer may not respond to '+scheduledTimerWithTimeInterval:target:selector:userinfo:repeat:'


Of course it doesn't work. And it says right there what is wrong.

You don't need help with XCode, you need help with spelling. Look at the selector _carefully_. Then look at the methods in NSTimer _carefully_. You may think there is a method named '+scheduledTimerWithTimeInterval:target:selector:userinfo:repeat:', but there isn't.