I need help with tis code I m getting error message,
here is the error message.
code here
with error message- NSTimer may not respond to '+scheduledTimerWithTimeInterval:target:selector:userinfo:repeat:'
Here is the whole code that I was working on
cheers
here is the error message.
code here
Code:
[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
Code:
#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
Last edited by a moderator: