All Data Structures Files Functions Variables Enumerations Enumerator Properties Defines
/Projects/Cogito/src/Layers/Menu/InstructionsLayer.m
Go to the documentation of this file.
00001 //
00002 //  InstructionsLayer.m
00003 //  Author: Thomas Taylor
00004 //
00005 //  Plays the instructions animation
00006 //
00007 //  20/01/2012: Created class
00008 //
00009 
00010 #import "InstructionsLayer.h"
00011 
00012 @interface InstructionsLayer()
00013 
00014 -(void)initBackground;
00015 -(void)initSlideViewer;
00016 -(void)initMenuButton;
00017 -(void)loadMainMenu;
00018 
00019 @end
00020 
00021 @implementation InstructionsLayer
00022 
00023 #pragma mark -
00024 #pragma mark Initialisation
00025 
00030 -(id)init 
00031 {
00032  self = [super init];
00033     
00034  if (self != nil) 
00035  {
00036   [self initBackground];
00037         [self initMenuButton];
00038         [self initSlideViewer];
00039  }
00040     
00041  return self;
00042 }
00043 
00047 -(void)initBackground
00048 {
00049     CGSize winSize = [CCDirector sharedDirector].winSize;
00050     
00051     // add default backdround to make transitions look nicer 
00052     CCSprite *background = [CCSprite spriteWithFile:kFilenameDefBG];
00053     [background setPosition:ccp(winSize.width/2, winSize.height/2)];
00054     [self addChild:background z:0];
00055 }
00056 
00060 -(void)initSlideViewer
00061 {
00062     // create the slides
00063     CCArray* slides = [CCArray arrayWithCapacity:3];
00064     [slides addObject:[[Slide alloc] initWithImage:@"InstructionsIntroduction.png"]];
00065     [slides addObject:[[Slide alloc] initWithImage:@"InstructionsNewGame.png"]];
00066     [slides addObject:[[Slide alloc] initWithImage:@"InstructionsLevel.png"]];
00067     [slides addObject:[[Slide alloc] initWithImage:@"InstructionsPause.png"]];
00068     [slides addObject:[[Slide alloc] initWithImage:@"InstructionsGameOver.png"]];
00069     
00070     slideViewer = [[SlideViewer alloc] initWithSlides:slides];
00071     [self addChild:slideViewer];
00072 }
00073 
00077 -(void)initMenuButton
00078 {
00079     // create and add the menu button
00080     CCMenuItemImage *_menuButton = [CCMenuItemImage itemFromNormalImage:@"Back.png" selectedImage:@"Back_down.png" disabledImage:nil target:self selector:@selector(loadMainMenu)];
00081     menuButton = [CCMenu menuWithItems:_menuButton, nil];
00082     [menuButton setPosition: ccp(80, 25)];
00083     [self addChild:menuButton z:100];
00084 }
00085 
00089 -(void)loadMainMenu 
00090 {
00091     [[GameManager sharedGameManager] runSceneWithID:kMainMenuScene];
00092 }
00093 
00094 @end