bug with game loop
I am making a game on xcode 5. I am using a nstimer and it has a bug with
my game loop. Can you help me please. All help is great.
@implementation ViewController
@synthesize bg, rock, platform1, platform2, platform3, platform4,
platform5, platform6, platform7;
@synthesize gameState;
@synthesize rockVelocity, gravity;
// Implement viewDidLoad to do additional setup after loading the view,
typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
gameState = kStateRunning;
rockVelocity = 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)
{
}
else if (gameState == kStateGameOver)
{
}
}
-(void)gameStatePlayNormal {
rockVelocity.y += gravity.y;
rock.center = CGPoint(rock.center.x + ballVelocity.x,rock.center.y
+ rockVelocity.y);
}
No comments:
Post a Comment