-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transformed into cocos2d 1.0 ios template project.
- Loading branch information
Showing
228 changed files
with
52,172 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// | ||
// Prefix header for all source files of the 'CCMenuAdvanced' target in the 'CCMenuAdvanced' project | ||
// | ||
|
||
#ifdef __OBJC__ | ||
#import <Foundation/Foundation.h> | ||
#import <UIKit/UIKit.h> | ||
#endif |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// CCMenuAdvancedAppDelegate.h | ||
// CCMenuAdvanced | ||
// | ||
// Created by Stepan Generalov on 14.04.11. | ||
// Copyright __MyCompanyName__ 2011. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@class RootViewController; | ||
|
||
@interface CCMenuAdvancedAppDelegate : NSObject <UIApplicationDelegate> { | ||
UIWindow *window; | ||
RootViewController *viewController; | ||
} | ||
|
||
@property (nonatomic, retain) UIWindow *window; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
// | ||
// CCMenuAdvancedAppDelegate.m | ||
// CCMenuAdvanced | ||
// | ||
// Created by Stepan Generalov on 14.04.11. | ||
// Copyright __MyCompanyName__ 2011. All rights reserved. | ||
// | ||
|
||
#import "cocos2d.h" | ||
|
||
#import "CCMenuAdvancedAppDelegate.h" | ||
#import "GameConfig.h" | ||
#import "HelloWorldLayer.h" | ||
#import "RootViewController.h" | ||
|
||
@implementation CCMenuAdvancedAppDelegate | ||
|
||
@synthesize window; | ||
|
||
- (void) removeStartupFlicker | ||
{ | ||
// | ||
// THIS CODE REMOVES THE STARTUP FLICKER | ||
// | ||
// Uncomment the following code if you Application only supports landscape mode | ||
// | ||
#if GAME_AUTOROTATION == kGameAutorotationUIViewController | ||
|
||
// CC_ENABLE_DEFAULT_GL_STATES(); | ||
// CCDirector *director = [CCDirector sharedDirector]; | ||
// CGSize size = [director winSize]; | ||
// CCSprite *sprite = [CCSprite spriteWithFile:@"Default.png"]; | ||
// sprite.position = ccp(size.width/2, size.height/2); | ||
// sprite.rotation = -90; | ||
// [sprite visit]; | ||
// [[director openGLView] swapBuffers]; | ||
// CC_ENABLE_DEFAULT_GL_STATES(); | ||
|
||
#endif // GAME_AUTOROTATION == kGameAutorotationUIViewController | ||
} | ||
- (void) applicationDidFinishLaunching:(UIApplication*)application | ||
{ | ||
// Init the window | ||
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | ||
|
||
// Try to use CADisplayLink director | ||
// if it fails (SDK < 3.1) use the default director | ||
if( ! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink] ) | ||
[CCDirector setDirectorType:kCCDirectorTypeDefault]; | ||
|
||
|
||
CCDirector *director = [CCDirector sharedDirector]; | ||
|
||
// Init the View Controller | ||
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; | ||
viewController.wantsFullScreenLayout = YES; | ||
|
||
// | ||
// Create the EAGLView manually | ||
// 1. Create a RGB565 format. Alternative: RGBA8 | ||
// 2. depth format of 0 bit. Use 16 or 24 bit for 3d effects, like CCPageTurnTransition | ||
// | ||
// | ||
EAGLView *glView = [EAGLView viewWithFrame:[window bounds] | ||
pixelFormat:kEAGLColorFormatRGB565 // kEAGLColorFormatRGBA8 | ||
depthFormat:0 // GL_DEPTH_COMPONENT16_OES | ||
]; | ||
|
||
// attach the openglView to the director | ||
[director setOpenGLView:glView]; | ||
|
||
// // Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices | ||
// if( ! [director enableRetinaDisplay:YES] ) | ||
// CCLOG(@"Retina Display Not supported"); | ||
|
||
// | ||
// VERY IMPORTANT: | ||
// If the rotation is going to be controlled by a UIViewController | ||
// then the device orientation should be "Portrait". | ||
// | ||
// IMPORTANT: | ||
// By default, this template only supports Landscape orientations. | ||
// Edit the RootViewController.m file to edit the supported orientations. | ||
// | ||
#if GAME_AUTOROTATION == kGameAutorotationUIViewController | ||
[director setDeviceOrientation:kCCDeviceOrientationPortrait]; | ||
#else | ||
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft]; | ||
#endif | ||
|
||
[director setAnimationInterval:1.0/60]; | ||
[director setDisplayFPS:YES]; | ||
|
||
|
||
// make the OpenGLView a child of the view controller | ||
[viewController setView:glView]; | ||
|
||
// make the View Controller a child of the main window | ||
[window addSubview: viewController.view]; | ||
|
||
[window makeKeyAndVisible]; | ||
|
||
// Default texture format for PNG/BMP/TIFF/JPEG/GIF images | ||
// It can be RGBA8888, RGBA4444, RGB5_A1, RGB565 | ||
// You can change anytime. | ||
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888]; | ||
|
||
|
||
// Removes the startup flicker | ||
[self removeStartupFlicker]; | ||
|
||
// Run the intro Scene | ||
[[CCDirector sharedDirector] runWithScene: [HelloWorldLayer scene]]; | ||
} | ||
|
||
|
||
- (void)applicationWillResignActive:(UIApplication *)application { | ||
[[CCDirector sharedDirector] pause]; | ||
} | ||
|
||
- (void)applicationDidBecomeActive:(UIApplication *)application { | ||
[[CCDirector sharedDirector] resume]; | ||
} | ||
|
||
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { | ||
[[CCDirector sharedDirector] purgeCachedData]; | ||
} | ||
|
||
-(void) applicationDidEnterBackground:(UIApplication*)application { | ||
[[CCDirector sharedDirector] stopAnimation]; | ||
} | ||
|
||
-(void) applicationWillEnterForeground:(UIApplication*)application { | ||
[[CCDirector sharedDirector] startAnimation]; | ||
} | ||
|
||
- (void)applicationWillTerminate:(UIApplication *)application { | ||
CCDirector *director = [CCDirector sharedDirector]; | ||
|
||
[[director openGLView] removeFromSuperview]; | ||
|
||
[viewController release]; | ||
|
||
[window release]; | ||
|
||
[director end]; | ||
} | ||
|
||
- (void)applicationSignificantTimeChange:(UIApplication *)application { | ||
[[CCDirector sharedDirector] setNextDeltaTimeZero:YES]; | ||
} | ||
|
||
- (void)dealloc { | ||
[[CCDirector sharedDirector] release]; | ||
[window release]; | ||
[super dealloc]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// GameConfig.h | ||
// CCMenuAdvanced | ||
// | ||
// Created by Stepan Generalov on 14.04.11. | ||
// Copyright __MyCompanyName__ 2011. All rights reserved. | ||
// | ||
|
||
#ifndef __GAME_CONFIG_H | ||
#define __GAME_CONFIG_H | ||
|
||
// | ||
// Supported Autorotations: | ||
// None, | ||
// UIViewController, | ||
// CCDirector | ||
// | ||
#define kGameAutorotationNone 0 | ||
#define kGameAutorotationCCDirector 1 | ||
#define kGameAutorotationUIViewController 2 | ||
|
||
// | ||
// Define here the type of autorotation that you want for your game | ||
// | ||
|
||
// 3rd generation and newer devices: Rotate using UIViewController. Rotation should be supported on iPad apps. | ||
// TIP: | ||
// To improve the performance, you should set this value to "kGameAutorotationNone" or "kGameAutorotationCCDirector" | ||
#if defined(__ARM_NEON__) || TARGET_IPHONE_SIMULATOR | ||
#define GAME_AUTOROTATION kGameAutorotationUIViewController | ||
|
||
// ARMv6 (1st and 2nd generation devices): Don't rotate. It is very expensive | ||
#elif __arm__ | ||
#define GAME_AUTOROTATION kGameAutorotationNone | ||
|
||
|
||
// Ignore this value on Mac | ||
#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) | ||
|
||
#else | ||
#error(unknown architecture) | ||
#endif | ||
|
||
#endif // __GAME_CONFIG_H | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// HelloWorldLayer.h | ||
// CCMenuAdvanced | ||
// | ||
// Created by Stepan Generalov on 14.04.11. | ||
// Copyright __MyCompanyName__ 2011. All rights reserved. | ||
// | ||
|
||
|
||
// When you import this file, you import all the cocos2d classes | ||
#import "cocos2d.h" | ||
|
||
// HelloWorldLayer | ||
@interface HelloWorldLayer : CCLayer | ||
{ | ||
} | ||
|
||
// returns a CCScene that contains the HelloWorldLayer as the only child | ||
+(CCScene *) scene; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// | ||
// HelloWorldLayer.m | ||
// CCMenuAdvanced | ||
// | ||
// Created by Stepan Generalov on 14.04.11. | ||
// Copyright __MyCompanyName__ 2011. All rights reserved. | ||
// | ||
|
||
|
||
// Import the interfaces | ||
#import "HelloWorldLayer.h" | ||
|
||
// HelloWorldLayer implementation | ||
@implementation HelloWorldLayer | ||
|
||
+(CCScene *) scene | ||
{ | ||
// 'scene' is an autorelease object. | ||
CCScene *scene = [CCScene node]; | ||
|
||
// 'layer' is an autorelease object. | ||
HelloWorldLayer *layer = [HelloWorldLayer node]; | ||
|
||
// add layer as a child to scene | ||
[scene addChild: layer]; | ||
|
||
// return the scene | ||
return scene; | ||
} | ||
|
||
// on "init" you need to initialize your instance | ||
-(id) init | ||
{ | ||
// always call "super" init | ||
// Apple recommends to re-assign "self" with the "super" return value | ||
if( (self=[super init])) { | ||
|
||
// create and initialize a Label | ||
CCLabelTTF *label = [CCLabelTTF labelWithString:@"Hello World" fontName:@"Marker Felt" fontSize:64]; | ||
|
||
// ask director the the window size | ||
CGSize size = [[CCDirector sharedDirector] winSize]; | ||
|
||
// position the label on the center of the screen | ||
label.position = ccp( size.width /2 , size.height/2 ); | ||
|
||
// add the label as a child to this Layer | ||
[self addChild: label]; | ||
} | ||
return self; | ||
} | ||
|
||
// on "dealloc" you need to release all your retained objects | ||
- (void) dealloc | ||
{ | ||
// in case you have something to dealloc, do it in this method | ||
// in this particular example nothing needs to be released. | ||
// cocos2d will automatically release all the children (Label) | ||
|
||
// don't forget to call "super dealloc" | ||
[super dealloc]; | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// RootViewController.h | ||
// CCMenuAdvanced | ||
// | ||
// Created by Stepan Generalov on 14.04.11. | ||
// Copyright __MyCompanyName__ 2011. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
|
||
@interface RootViewController : UIViewController { | ||
|
||
} | ||
|
||
@end |
Oops, something went wrong.