--- a/cocoaTouch/overlayViewController.m Wed Mar 17 22:56:23 2010 +0000
+++ b/cocoaTouch/overlayViewController.m Thu Mar 18 02:18:50 2010 +0000
@@ -10,6 +10,8 @@
#import "PascalImports.h"
@implementation overlayViewController
+@synthesize dimTimer;
+
-(void) didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
@@ -18,12 +20,23 @@
// Release any cached data, images, etc that aren't in use.
}
+-(void) viewDidLoad {
+ dimTimer = [[NSTimer alloc] initWithFireDate:[NSDate dateWithTimeIntervalSinceNow:6]
+ interval:1000
+ target:self
+ selector:@selector(dimOverlay)
+ userInfo:nil
+ repeats:YES];
+
+ [[NSRunLoop currentRunLoop] addTimer:dimTimer forMode:NSDefaultRunLoopMode];
+}
+
-(void) viewDidUnload {
- // Release any retained subviews of the main view.
- // e.g. self.myOutlet = nil;
+ [dimTimer invalidate];
}
-(void) dealloc {
+ [dimTimer release];
[super dealloc];
}
@@ -31,9 +44,10 @@
// dim the overlay when there's no more input for a certain amount of time
-(IBAction) buttonReleased:(id) sender {
HW_allKeysUp();
- [NSTimer scheduledTimerWithTimeInterval:2.8 target:self selector:@selector(dimOverlay) userInfo:nil repeats:NO];
+ [dimTimer setFireDate:[NSDate dateWithTimeIntervalSinceNow:2.7]];
}
+// nice transition for dimming
-(void) dimOverlay {
[UIView beginAnimations:@"overlay dim" context:NULL];
[UIView setAnimationDuration:0.6];
@@ -41,14 +55,16 @@
[UIView commitAnimations];
}
+// set the overlay visible and put off the timer for enough time
-(void) activateOverlay {
self.view.alpha = 1;
+ [dimTimer setFireDate:[NSDate dateWithTimeIntervalSinceNow:1000]];
}
// issue certain action based on the tag of the button
-(IBAction) buttonPressed:(id) sender {
[self activateOverlay];
-
+
UIButton *theButton = (UIButton*)sender;
switch (theButton.tag) {
case 0:
@@ -67,12 +83,13 @@
HW_shoot();
break;
case 5:
- HW_pause();
+ HW_jump();
break;
case 6:
- HW_chat();
+ HW_backjump();
break;
default:
+ // HW_chat() HW_tab() HW_pause()
break;
}
}