cocoaTouch/overlayViewController.m
author koda
Wed, 17 Mar 2010 00:26:35 +0000
changeset 3006 da6023c2745b
child 3015 20a9c8160e82
permissions -rw-r--r--
restore compilation on simulator and device new architecture for implementing controls controls implmented with a joystick (partially done) lotsa code cleanup
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3006
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
     1
//
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
     2
//  overlayViewController.m
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
     3
//  HedgewarsMobile
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
     4
//
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
     5
//  Created by Vittorio on 16/03/10.
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
     6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
     7
//
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
     8
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
     9
#import "overlayViewController.h"
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    10
#import "PascalImports.h"
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    11
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    12
@implementation overlayViewController
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    13
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    14
-(void) didReceiveMemoryWarning {
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    15
	// Releases the view if it doesn't have a superview.
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    16
    [super didReceiveMemoryWarning];
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    17
	
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    18
	// Release any cached data, images, etc that aren't in use.
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    19
}
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    20
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    21
-(void) viewDidUnload {
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    22
	// Release any retained subviews of the main view.
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    23
	// e.g. self.myOutlet = nil;
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    24
}
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    25
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    26
-(void) dealloc {
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    27
    [super dealloc];
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    28
}
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    29
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    30
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    31
// dim the overlay when there's no more input for a certain amount of time
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    32
-(IBAction) buttonReleased:(id) sender {
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    33
	HW_allKeysUp();
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    34
    [NSTimer scheduledTimerWithTimeInterval:2.8 target:self selector:@selector(dimOverlay) userInfo:nil repeats:NO];
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    35
}
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    36
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    37
-(void) dimOverlay {
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    38
    [UIView beginAnimations:@"overlay dim" context:NULL];
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    39
   	[UIView setAnimationDuration:0.6];
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    40
    self.view.alpha = 0.2;
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    41
	[UIView commitAnimations];
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    42
}
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    43
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    44
-(void) activateOverlay {
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    45
    self.view.alpha = 1;
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    46
}
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    47
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    48
// issue certain action based on the tag of the button 
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    49
-(IBAction) buttonPressed:(id) sender {
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    50
    [self activateOverlay];
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    51
    
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    52
    UIButton *theButton = (UIButton*)sender;
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    53
    switch (theButton.tag) {
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    54
        case 0:
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    55
           	HW_walkLeft();
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    56
            break;
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    57
        case 1:
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    58
            HW_walkRight();
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    59
            break;
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    60
        case 2:
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    61
            HW_aimUp();
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    62
            break;
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    63
        case 3:
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    64
            HW_aimDown();
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    65
            break;
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    66
        case 4:
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    67
            HW_shoot();
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    68
            break;
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    69
        case 5:
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    70
            HW_pause();
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    71
            break;
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    72
        case 6:
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    73
            HW_chat();
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    74
            break;
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    75
        default:
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    76
            break;
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    77
    }
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    78
}
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    79
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    80
da6023c2745b restore compilation on simulator and device
koda
parents:
diff changeset
    81
@end