50 return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); |
50 return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); |
51 } |
51 } |
52 |
52 |
53 -(void) viewDidUnload { |
53 -(void) viewDidUnload { |
54 [dimTimer invalidate]; |
54 [dimTimer invalidate]; |
|
55 self.dimTimer = nil; |
|
56 menuPopover = nil; |
|
57 [super viewDidUnload]; |
55 } |
58 } |
56 |
59 |
57 -(void) dealloc { |
60 -(void) dealloc { |
58 [menuPopover release]; |
61 [menuPopover release]; |
59 // dimTimer is autoreleased |
62 // dimTimer is autoreleased |
91 } |
94 } |
92 |
95 |
93 // issue certain action based on the tag of the button |
96 // issue certain action based on the tag of the button |
94 -(IBAction) buttonPressed:(id) sender { |
97 -(IBAction) buttonPressed:(id) sender { |
95 [self activateOverlay]; |
98 [self activateOverlay]; |
96 UIActionSheet *actionSheet; |
|
97 UIButton *theButton = (UIButton *)sender; |
99 UIButton *theButton = (UIButton *)sender; |
98 |
100 |
99 switch (theButton.tag) { |
101 switch (theButton.tag) { |
100 case 0: |
102 case 0: |
101 HW_walkLeft(); |
103 HW_walkLeft(); |
152 HW_pause(); |
137 HW_pause(); |
153 } |
138 } |
154 |
139 |
155 // show up a popover containing a popupMenuViewController; we hook it with setPopoverContentSize |
140 // show up a popover containing a popupMenuViewController; we hook it with setPopoverContentSize |
156 -(IBAction) showPopover{ |
141 -(IBAction) showPopover{ |
157 PopupMenuViewController *popupMenu = [[PopupMenuViewController alloc] initWithNibName:@"PopupMenuViewController" bundle:nil]; |
142 PopupMenuViewController *popupMenu = [[PopupMenuViewController alloc] init]; |
158 |
143 |
159 menuPopover = [[UIPopoverController alloc] initWithContentViewController:popupMenu]; |
144 menuPopover = [[UIPopoverController alloc] initWithContentViewController:popupMenu]; |
160 [menuPopover setPopoverContentSize:CGSizeMake(220, 170) animated:YES]; |
145 [menuPopover setPopoverContentSize:CGSizeMake(220, 170) animated:YES]; |
161 |
146 |
162 /*UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; |
|
163 button.frame= CGRectMake(960, 0, 64, 64); |
|
164 button.titleLabel.text=@"UUUUUUUF"; |
|
165 [self.view addSubview:button];*/ |
|
166 |
|
167 [menuPopover presentPopoverFromRect:CGRectMake(960, 0, 220, 32) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES]; |
147 [menuPopover presentPopoverFromRect:CGRectMake(960, 0, 220, 32) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES]; |
168 //UIBarButtonItem *sender = [[useless items] objectAtIndex:1]; |
|
169 //[self.popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES]; |
|
170 } |
148 } |
171 |
149 |
172 // because of the actionSheet, the popOver might not get dismissed, so we do it manually (through a NSNotification system, see above) |
150 // because of the actionSheet, the popOver might not get dismissed, so we do it manually (through a NSNotification system, see above) |
173 -(void) dismissPopover { |
151 -(void) dismissPopover { |
174 if (menuPopover.popoverVisible) |
152 if (menuPopover.popoverVisible) |
175 [menuPopover dismissPopoverAnimated:YES]; |
153 [menuPopover dismissPopoverAnimated:YES]; |
176 } |
154 } |
177 |
155 |
178 #pragma mark - |
156 #pragma mark - |
|
157 #pragma mark Custom touch event handling |
|
158 |
179 #define kMinimumPinchDelta 50 |
159 #define kMinimumPinchDelta 50 |
180 #define kMinimumGestureLength 10 |
160 #define kMinimumGestureLength 10 |
181 #define kMaximumVariance 3 |
161 #define kMaximumVariance 3 |
182 |
162 |
183 -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { |
163 -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { |