I'm trying to make a timer to handle game logic, but it won't even run GameTimer is an NSTimer, and mainloop is a NSRunLoop.
I finnaly found out what #pragma is [smiley=WaveyWave2.gif]
[code c++]//
// AdventureViewController.m
// Adventure
//
// Created by Kurt Manion on 12/10/11.
// Copyright 2011 __Compleatly_Coded__. All rights reserved.
//
#import "Adventure_Prefix.pch"
#import "AdventureViewController.h"
@implementation AdventureViewController
@synthesize GameTimer;
@synthesize mainloop;
#pragma mark -
#pragma mark Touches
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSSet* allTouches = [event allTouches];
UITouch* touch = [[allTouches allObjects] objectAtIndex:0];
//UIView* Frame = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
CGPoint Location = [touch locationInView:nil];
//int *quadrants;
NSLog(@"touch at location:%@",NSStringFromCGPoint(Location));
}
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
//[GameTimer invalidate];
NSLog(@"Touches ended");
}
#pragma mark -
#pragma mark CustomInitalizer
// 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
[self makeTimer];
[self startTimer];
UIImage* Sprite = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Sprite" ofType:@"gif"]];
UIImageView* Hero = [[UIImageView alloc] initWithImage:Sprite];
[self.view insertSubview:Hero atIndex:1];
Hero.center = CGPointMake(CENTER);
[Sprite retain];
[Hero retain];
}
return self;
}
- (void)dealloc {
[super dealloc];
[GameTimer release];
[mainloop release];
}
#pragma mark -
#pragma mark SetUpTimer
- (void) makeTimer {
NSLog(@"making timer");
NSTimer* Timer = [NSTimer scheduledTimerWithTimeInterval:0.2
target:nil
selector:@selector(movehero)
userInfo:nil
repeats:YES];
self.GameTimer = Timer;
}
- (void) startTimer {
NSLog(@"starting timer");
[mainloop addTimer:GameTimer forMode:NSDefaultRunLoopMode];
[mainloop run];
}
- (void) movehero {
NSLog(@"Move Hero");
}
/*
// 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];
}
*/
#pragma mark -
#pragma mark CustomRules
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
/*
- (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;
}
*/
@end
[/code]