Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // MainMenu.m
- // OrcInvasion
- //
- // Created by Mahmood1 on 1/11/12.
- // Copyright (c) 2012 __MyCompanyName__. All rights reserved.
- //
- #import "MainMenu.h"
- #import "OIheaders.h"
- #import "Retronator.Xni.Framework.Content.h"
- #import "Retronator.Xni.Framework.Content.Pipeline.Processors.h"
- @implementation MainMenu
- - (id) initWithGame:(Game *)theGame {
- self = [super initWithGame:theGame];
- if (self != nil) {
- inputArea = [[Rectangle alloc] initWithRectangle:theGame.window.clientBounds];
- scene = [[Scene alloc] init];
- // Fonts
- FontTextureProcessor *fontProcessor = [[[FontTextureProcessor alloc] init] autorelease];
- font = [[self.game.content load:@"Fonts" processor:fontProcessor] autorelease];
- background = [[self.game.content load:@"Background"] autorelease];
- title = [[Label alloc] initWithFont:font text:@"ORC INVASION!" position:[Vector2 vectorWithX:15 y:150]];
- [title setScaleUniform:2];
- [title setColor:[Color forestGreen]];
- [scene addItem:title];
- text = [[Label alloc] initWithFont:font text:@"PRESS TO PLAY" position:[Vector2 vectorWithX:10 y:200]];
- [text setScaleUniform:2];
- [text setColor:[Color red]];
- [scene addItem:text];
- backgroundImage = [[Image alloc] initWithTexture:background position:[Vector2 vectorWithX:0 y:0]];
- [scene addItem:backgroundImage];
- renderer = [[GUIRenderer alloc] initWithGame:self.game scene:scene];
- }
- return self;
- }
- - (void) activate {
- [self.game.components addComponent:renderer];
- }
- - (void) deactivate {
- [self.game.components removeComponent:renderer];
- }
- - (void) initialize {
- [super initialize];
- }
- - (void) updateWithGameTime:(GameTime *)gameTime {
- TouchCollection *touches = [[TouchPanel getInstance] getState];
- if ([touches count] == 1 ) {
- TouchLocation *touch = [touches objectAtIndex:0];
- if ([inputArea containsX:touch.position.x y:touch.position.y]) {
- Gameplay *gameplay = [[[Gameplay alloc] initWithGame:self.game]autorelease];
- [orcInvasion pushState:gameplay];
- }
- }
- }
- - (void) dealloc
- {
- [backgroundImage release];
- [text release];
- [font release];
- [background release];
- [title release];
- [scene release];
- [renderer release];
- [super dealloc];
- }
- @end
Add Comment
Please, Sign In to add comment