Guest User

Untitled

a guest
May 21st, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  MainMenu.m
  3. //  OrcInvasion
  4. //
  5. //  Created by Mahmood1 on 1/11/12.
  6. //  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
  7. //
  8.  
  9. #import "MainMenu.h"
  10. #import "OIheaders.h"
  11.  
  12. #import "Retronator.Xni.Framework.Content.h"
  13.  
  14. #import "Retronator.Xni.Framework.Content.Pipeline.Processors.h"
  15.  
  16. @implementation MainMenu
  17.  
  18. - (id) initWithGame:(Game *)theGame {
  19.     self = [super initWithGame:theGame];
  20.     if (self != nil) {
  21.         inputArea = [[Rectangle alloc] initWithRectangle:theGame.window.clientBounds];
  22.         scene = [[Scene alloc] init];
  23.        
  24.         // Fonts
  25.         FontTextureProcessor *fontProcessor = [[[FontTextureProcessor alloc] init] autorelease];
  26.         font = [[self.game.content load:@"Fonts" processor:fontProcessor] autorelease];
  27.         background = [[self.game.content load:@"Background"] autorelease];
  28.        
  29.        
  30.         title = [[Label alloc] initWithFont:font text:@"ORC INVASION!" position:[Vector2 vectorWithX:15 y:150]];
  31.         [title setScaleUniform:2];
  32.         [title setColor:[Color forestGreen]];
  33.         [scene addItem:title];
  34.        
  35.         text = [[Label alloc] initWithFont:font text:@"PRESS TO PLAY" position:[Vector2 vectorWithX:10 y:200]];
  36.         [text setScaleUniform:2];
  37.         [text setColor:[Color red]];
  38.         [scene addItem:text];
  39.        
  40.         backgroundImage = [[Image alloc] initWithTexture:background position:[Vector2 vectorWithX:0 y:0]];
  41.         [scene addItem:backgroundImage];
  42.        
  43.         renderer = [[GUIRenderer alloc] initWithGame:self.game scene:scene];
  44.     }
  45.     return self;
  46. }
  47.  
  48. - (void) activate {
  49.     [self.game.components addComponent:renderer];  
  50. }
  51.  
  52. - (void) deactivate {
  53.     [self.game.components removeComponent:renderer];   
  54. }
  55.  
  56. - (void) initialize {
  57.    
  58.     [super initialize];
  59. }
  60.  
  61. - (void) updateWithGameTime:(GameTime *)gameTime {
  62.     TouchCollection *touches = [[TouchPanel getInstance] getState];
  63.  
  64.     if ([touches count] == 1 ) {
  65.         TouchLocation *touch = [touches objectAtIndex:0];        
  66.         if ([inputArea containsX:touch.position.x y:touch.position.y]) {            
  67.             Gameplay *gameplay = [[[Gameplay alloc] initWithGame:self.game]autorelease];
  68.             [orcInvasion pushState:gameplay];
  69.         }    
  70.     }
  71. }
  72.  
  73. - (void) dealloc
  74. {
  75.     [backgroundImage release];
  76.     [text release];
  77.     [font release];
  78.     [background release];
  79.     [title release];
  80.     [scene release];
  81.     [renderer release];  
  82.     [super dealloc];
  83. }
  84.  
  85.  
  86. @end
Add Comment
Please, Sign In to add comment