cocoaTouch/overlayViewController.m
changeset 3006 da6023c2745b
child 3015 20a9c8160e82
equal deleted inserted replaced
3005:1ff835e9ce32 3006:da6023c2745b
       
     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
       
    13 
       
    14 -(void) didReceiveMemoryWarning {
       
    15 	// Releases the view if it doesn't have a superview.
       
    16     [super didReceiveMemoryWarning];
       
    17 	
       
    18 	// Release any cached data, images, etc that aren't in use.
       
    19 }
       
    20 
       
    21 -(void) viewDidUnload {
       
    22 	// Release any retained subviews of the main view.
       
    23 	// e.g. self.myOutlet = nil;
       
    24 }
       
    25 
       
    26 -(void) dealloc {
       
    27     [super dealloc];
       
    28 }
       
    29 
       
    30 
       
    31 // dim the overlay when there's no more input for a certain amount of time
       
    32 -(IBAction) buttonReleased:(id) sender {
       
    33 	HW_allKeysUp();
       
    34     [NSTimer scheduledTimerWithTimeInterval:2.8 target:self selector:@selector(dimOverlay) userInfo:nil repeats:NO];
       
    35 }
       
    36 
       
    37 -(void) dimOverlay {
       
    38     [UIView beginAnimations:@"overlay dim" context:NULL];
       
    39    	[UIView setAnimationDuration:0.6];
       
    40     self.view.alpha = 0.2;
       
    41 	[UIView commitAnimations];
       
    42 }
       
    43 
       
    44 -(void) activateOverlay {
       
    45     self.view.alpha = 1;
       
    46 }
       
    47 
       
    48 // issue certain action based on the tag of the button 
       
    49 -(IBAction) buttonPressed:(id) sender {
       
    50     [self activateOverlay];
       
    51     
       
    52     UIButton *theButton = (UIButton*)sender;
       
    53     switch (theButton.tag) {
       
    54         case 0:
       
    55            	HW_walkLeft();
       
    56             break;
       
    57         case 1:
       
    58             HW_walkRight();
       
    59             break;
       
    60         case 2:
       
    61             HW_aimUp();
       
    62             break;
       
    63         case 3:
       
    64             HW_aimDown();
       
    65             break;
       
    66         case 4:
       
    67             HW_shoot();
       
    68             break;
       
    69         case 5:
       
    70             HW_pause();
       
    71             break;
       
    72         case 6:
       
    73             HW_chat();
       
    74             break;
       
    75         default:
       
    76             break;
       
    77     }
       
    78 }
       
    79 
       
    80 
       
    81 @end