All Data Structures Files Functions Variables Enumerations Enumerator Properties Defines
/Projects/Cogito/src/Layers/Menu/StatsLayer.m
Go to the documentation of this file.
00001 //
00002 //  StatsLayer.m
00003 //  Author: Thomas Taylor
00004 //
00005 //  The 'stats' layer
00006 //
00007 //  06/03/2012: Created class
00008 //
00009 
00010 #import "StatsLayer.h"
00011 
00012 @interface StatsLayer()
00013 
00014 -(void)initBackground;
00015 -(void)initMenuButton;
00016 -(void)initSlideViewer;
00017 -(void)onBackButtonPressed;
00018 
00019 @end
00020 
00021 @implementation StatsLayer
00022 
00023 #pragma mark -
00024 #pragma mark Memory Allocation
00025 
00026 -(void)dealloc
00027 {
00028     [slideViewer release];
00029     [super dealloc];
00030 }
00031 
00032 #pragma mark -
00033 #pragma mark Initialisation
00034 
00039 -(id)init
00040 {
00041     CCLOG(@"%@.init", NSStringFromClass([self class]));
00042     
00043  self = [super init];
00044     
00045  if (self != nil) 
00046     {
00047         [self initBackground];
00048         [self initMenuButton];
00049         [self initSlideViewer];
00050     }
00051  return self;
00052 }
00053 
00057 -(void)initBackground
00058 {
00059     CGSize winSize = [CCDirector sharedDirector].winSize; 
00060     CCSprite *background = [CCSprite spriteWithFile:kFilenameDefBG];
00061     [background setPosition:ccp(winSize.width/2, winSize.height/2)];
00062     [self addChild:background];
00063 }
00064 
00068 -(void)initMenuButton
00069 {    
00070     // create the button and add to the menu
00071     CCMenuItemImage *menuButton = [CCMenuItemImage itemFromNormalImage:@"Back.png" selectedImage:@"Back_down.png" disabledImage:nil target:self selector:@selector(onBackButtonPressed)];
00072     backButton = [CCMenu menuWithItems:menuButton, nil];
00073     
00074     // position and add the menu
00075     [backButton setPosition: ccp(70, 20)];
00076     [self addChild:backButton];
00077 }
00078 
00082 -(void)initSlideViewer
00083 {
00084     // create the slides
00085     CCArray* slides = [CCArray arrayWithCapacity:3];
00086     [slides addObject:[[GraphSlide alloc] initWithImage:@"EpisodeGraph.png" type:kGraphEpisodeTime]];
00087     [slides addObject:[[GraphSlide alloc] initWithImage:@"ActionsGraph.png" type:kGraphActions]];
00088     [slides addObject:[[GraphSlide alloc] initWithImage:@"AgentsSaved.png" type:kGraphAgentsSaved]];
00089     
00090     slideViewer = [[SlideViewer alloc] initWithSlides:slides];
00091     [self addChild:slideViewer];
00092 }
00093 
00097 -(void)onBackButtonPressed 
00098 {
00099  [[GameManager sharedGameManager] runSceneWithID:kMainMenuScene];
00100 }
00101 
00102 @end