Permalink
Browse files

show welcome scene

  • Loading branch information...
1 parent 935d2fd commit 9f6c64cda683c0633bf61200797899d96efa8e71 @oscardelben committed May 24, 2011
@@ -124,6 +124,7 @@
557249F6136EBFAD00046EAC /* SnakeLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 557249F5136EBFAD00046EAC /* SnakeLayer.m */; };
557249F8136EC0C200046EAC /* snake-body.png in Resources */ = {isa = PBXBuildFile; fileRef = 557249F7136EC0C200046EAC /* snake-body.png */; };
557249FE136EDF9600046EAC /* background.png in Resources */ = {isa = PBXBuildFile; fileRef = 557249FD136EDF9600046EAC /* background.png */; };
+ 5584193C138BB75C002E92D8 /* WelcomeLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 5584193B138BB75C002E92D8 /* WelcomeLayer.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -364,6 +365,8 @@
557249F5136EBFAD00046EAC /* SnakeLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SnakeLayer.m; sourceTree = "<group>"; };
557249F7136EC0C200046EAC /* snake-body.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "snake-body.png"; sourceTree = "<group>"; };
557249FD136EDF9600046EAC /* background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = background.png; sourceTree = "<group>"; };
+ 5584193A138BB75C002E92D8 /* WelcomeLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WelcomeLayer.h; sourceTree = "<group>"; };
+ 5584193B138BB75C002E92D8 /* WelcomeLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WelcomeLayer.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -431,6 +434,8 @@
557249EE136EBE8800046EAC /* GameConfig.h */,
557249F4136EBFAD00046EAC /* SnakeLayer.h */,
557249F5136EBFAD00046EAC /* SnakeLayer.m */,
+ 5584193A138BB75C002E92D8 /* WelcomeLayer.h */,
+ 5584193B138BB75C002E92D8 /* WelcomeLayer.m */,
5572489B136EBE8500046EAC /* Resources */,
557248AF136EBE8600046EAC /* cocos2d */,
557249A1136EBE8700046EAC /* CocosDenshion */,
@@ -877,6 +882,7 @@
557249E7136EBE8800046EAC /* AppDelegate.m in Sources */,
557249EA136EBE8800046EAC /* RootViewController.m in Sources */,
557249F6136EBFAD00046EAC /* SnakeLayer.m in Sources */,
+ 5584193C138BB75C002E92D8 /* WelcomeLayer.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -11,6 +11,7 @@
#import "AppDelegate.h"
#import "GameConfig.h"
#import "SnakeLayer.h"
+#import "WelcomeLayer.h"
#import "RootViewController.h"
@implementation AppDelegate
@@ -110,7 +111,7 @@ - (void) applicationDidFinishLaunching:(UIApplication*)application
[self removeStartupFlicker];
// Run the intro Scene
- [[CCDirector sharedDirector] runWithScene: [SnakeLayer scene]];
+ [[CCDirector sharedDirector] runWithScene: [WelcomeLayer scene]];
}
@@ -8,6 +8,7 @@
#import "SnakeLayer.h"
#import "GameConfig.h"
+#import "WelcomeLayer.h"
#define kColumnIndex 0
#define kRowIndex 1
@@ -303,6 +304,7 @@ - (void)advance:(ccTime)dt
- (void)crash
{
self.gameRunning = NO;
+ [[CCDirector sharedDirector] replaceScene:[WelcomeLayer scene]];
}
#pragma mark -
@@ -0,0 +1,19 @@
+//
+// WelcomeLayer.h
+// Snake4iPhone
+//
+// Created by Oscar Del Ben on 5/24/11.
+// Copyright 2011 DibiStore. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+#import "cocos2d.h"
+
+@interface WelcomeLayer : CCLayer {
+
+}
+
++(CCScene *) scene;
+
+@end
@@ -0,0 +1,54 @@
+//
+// WelcomeLayer.m
+// Snake4iPhone
+//
+// Created by Oscar Del Ben on 5/24/11.
+// Copyright 2011 DibiStore. All rights reserved.
+//
+
+#import "WelcomeLayer.h"
+#import "SnakeLayer.h"
+
+@implementation WelcomeLayer
+
++(CCScene *) scene
+{
+ // 'scene' is an autorelease object.
+ CCScene *scene = [CCScene node];
+
+ // 'layer' is an autorelease object.
+ WelcomeLayer *layer = [WelcomeLayer node];
+
+ // add layer as a child to scene
+ [scene addChild: layer];
+
+ // return the scene
+ return scene;
+}
+
+-(id) init
+{
+ self = [super init];
+ if (self)
+ {
+ CCMenuItem *item = [CCMenuItemFont itemFromString: @"Start Game" target:self selector:@selector(startGame)];
+ CCMenu *myMenu = [CCMenu menuWithItems:item, nil];
+
+ [self addChild:myMenu];
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+ [super dealloc];
+}
+
+- (void)startGame
+{
+ [[CCDirector sharedDirector] replaceScene:[SnakeLayer scene]];
+}
+
+
+@end

0 comments on commit 9f6c64c

Please sign in to comment.