3006
|
1 |
//
|
|
2 |
// overlayViewController.m
|
|
3 |
// HedgewarsMobile
|
|
4 |
//
|
|
5 |
// Created by Vittorio on 16/03/10.
|
|
6 |
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
|
7 |
//
|
|
8 |
|
|
9 |
#import "overlayViewController.h"
|
|
10 |
#import "PascalImports.h"
|
|
11 |
|
|
12 |
@implementation overlayViewController
|
3015
|
13 |
@synthesize dimTimer;
|
|
14 |
|
3006
|
15 |
|
|
16 |
-(void) didReceiveMemoryWarning {
|
|
17 |
// Releases the view if it doesn't have a superview.
|
|
18 |
[super didReceiveMemoryWarning];
|
|
19 |
|
|
20 |
// Release any cached data, images, etc that aren't in use.
|
|
21 |
}
|
|
22 |
|
3015
|
23 |
-(void) viewDidLoad {
|
|
24 |
dimTimer = [[NSTimer alloc] initWithFireDate:[NSDate dateWithTimeIntervalSinceNow:6]
|
|
25 |
interval:1000
|
|
26 |
target:self
|
|
27 |
selector:@selector(dimOverlay)
|
|
28 |
userInfo:nil
|
|
29 |
repeats:YES];
|
|
30 |
|
|
31 |
[[NSRunLoop currentRunLoop] addTimer:dimTimer forMode:NSDefaultRunLoopMode];
|
|
32 |
}
|
|
33 |
|
3006
|
34 |
-(void) viewDidUnload {
|
3015
|
35 |
[dimTimer invalidate];
|
3006
|
36 |
}
|
|
37 |
|
|
38 |
-(void) dealloc {
|
3015
|
39 |
[dimTimer release];
|
3006
|
40 |
[super dealloc];
|
|
41 |
}
|
|
42 |
|
|
43 |
|
|
44 |
// dim the overlay when there's no more input for a certain amount of time
|
|
45 |
-(IBAction) buttonReleased:(id) sender {
|
|
46 |
HW_allKeysUp();
|
3015
|
47 |
[dimTimer setFireDate:[NSDate dateWithTimeIntervalSinceNow:2.7]];
|
3006
|
48 |
}
|
|
49 |
|
3015
|
50 |
// nice transition for dimming
|
3006
|
51 |
-(void) dimOverlay {
|
|
52 |
[UIView beginAnimations:@"overlay dim" context:NULL];
|
|
53 |
[UIView setAnimationDuration:0.6];
|
|
54 |
self.view.alpha = 0.2;
|
|
55 |
[UIView commitAnimations];
|
|
56 |
}
|
|
57 |
|
3015
|
58 |
// set the overlay visible and put off the timer for enough time
|
3006
|
59 |
-(void) activateOverlay {
|
|
60 |
self.view.alpha = 1;
|
3015
|
61 |
[dimTimer setFireDate:[NSDate dateWithTimeIntervalSinceNow:1000]];
|
3006
|
62 |
}
|
|
63 |
|
|
64 |
// issue certain action based on the tag of the button
|
|
65 |
-(IBAction) buttonPressed:(id) sender {
|
|
66 |
[self activateOverlay];
|
3015
|
67 |
|
3006
|
68 |
UIButton *theButton = (UIButton*)sender;
|
|
69 |
switch (theButton.tag) {
|
|
70 |
case 0:
|
|
71 |
HW_walkLeft();
|
|
72 |
break;
|
|
73 |
case 1:
|
|
74 |
HW_walkRight();
|
|
75 |
break;
|
|
76 |
case 2:
|
|
77 |
HW_aimUp();
|
|
78 |
break;
|
|
79 |
case 3:
|
|
80 |
HW_aimDown();
|
|
81 |
break;
|
|
82 |
case 4:
|
|
83 |
HW_shoot();
|
|
84 |
break;
|
|
85 |
case 5:
|
3015
|
86 |
HW_jump();
|
3006
|
87 |
break;
|
|
88 |
case 6:
|
3015
|
89 |
HW_backjump();
|
3006
|
90 |
break;
|
|
91 |
default:
|
3015
|
92 |
// HW_chat() HW_tab() HW_pause()
|
3006
|
93 |
break;
|
|
94 |
}
|
|
95 |
}
|
|
96 |
|
|
97 |
|
|
98 |
@end
|