Merge branch 'issue_388' of https://github.com/minggo/cocos2d-x into minggo-issue_388

This commit is contained in:
minggo 2011-03-10 16:29:25 +08:00
commit 22fa2967e3
31 changed files with 846 additions and 397 deletions

View File

@ -2,7 +2,7 @@
echo 'cocos2d-x template installer' echo 'cocos2d-x template installer'
COCOS2D_VER='cocos2d-0.99.5-x-0.7.2' COCOS2D_VER='cocos2d-0.99.5-x-0.8.0'
BASE_TEMPLATE_DIR="/Library/Application Support/Developer/Shared/Xcode" BASE_TEMPLATE_DIR="/Library/Application Support/Developer/Shared/Xcode"
BASE_TEMPLATE_USER_DIR="$HOME/Library/Application Support/Developer/Shared/Xcode" BASE_TEMPLATE_USER_DIR="$HOME/Library/Application Support/Developer/Shared/Xcode"

View File

@ -5,9 +5,10 @@
// Created by ___FULLUSERNAME___ on ___DATE___. // Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. // Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
// //
#include "HelloWorldScene.h" #include "HelloWorldScene.h"
using namespace cocos2d; USING_NS_CC;
CCScene* HelloWorld::scene() CCScene* HelloWorld::scene()
{ {
@ -48,7 +49,7 @@ bool HelloWorld::init()
// create menu, it's an autorelease object // create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL); CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL);
pMenu->setPosition( CGPointZero ); pMenu->setPosition( CCPointZero );
this->addChild(pMenu, 1); this->addChild(pMenu, 1);
///////////////////////////// /////////////////////////////
@ -56,10 +57,10 @@ bool HelloWorld::init()
// add a label shows "Hello World" // add a label shows "Hello World"
// create and initialize a label // create and initialize a label
CCLabelTTF* pLabel = CCLabelTTF::labelWithString("HelloWorld", "Thonburi", 34); CCLabelTTF* pLabel = CCLabelTTF::labelWithString("Hello World", "Thonburi", 34);
// ask director the window size // ask director the window size
CGSize size = CCDirector::sharedDirector()->getWinSize(); CCSize size = CCDirector::sharedDirector()->getWinSize();
// position the label on the center of the screen // position the label on the center of the screen
pLabel->setPosition( ccp(size.width / 2, size.height - 20) ); pLabel->setPosition( ccp(size.width / 2, size.height - 20) );
@ -73,13 +74,13 @@ bool HelloWorld::init()
// position the sprite on the center of the screen // position the sprite on the center of the screen
pSprite->setPosition( ccp(size.width/2, size.height/2) ); pSprite->setPosition( ccp(size.width/2, size.height/2) );
// ad the sprite as a child to this layer // add the sprite as a child to this layer
this->addChild(pSprite, 0); this->addChild(pSprite, 0);
return true; return true;
} }
void HelloWorld::menuCloseCallback(NSObject* pSender) void HelloWorld::menuCloseCallback(CCObject* pSender)
{ {
CCDirector::sharedDirector()->end(); CCDirector::sharedDirector()->end();
} }

View File

@ -5,8 +5,9 @@
// Created by ___FULLUSERNAME___ on ___DATE___. // Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. // Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
// //
#ifndef _HELLOWORLD_LAYER_H_
#define _HELLOWORLD_LAYER_H_ #ifndef __HELLOWORLD_SCENE_H__
#define __HELLOWORLD_SCENE_H__
#include "cocos2d.h" #include "cocos2d.h"
@ -20,10 +21,10 @@ public:
static cocos2d::CCScene* scene(); static cocos2d::CCScene* scene();
// a selector callback // a selector callback
virtual void menuCloseCallback(NSObject* pSender); virtual void menuCloseCallback(CCObject* pSender);
// implement the "static node()" method manually // implement the "static node()" method manually
LAYER_NODE_FUNC(HelloWorld); LAYER_NODE_FUNC(HelloWorld);
}; };
#endif // _HELLOWORLD_SCENE_H_ #endif // __HELLOWORLD_SCENE_H__

View File

@ -0,0 +1,14 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppController.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
@interface ___PROJECTNAMEASIDENTIFIER___AppController : NSObject <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate,UIApplicationDelegate> {
UIWindow *window;
}
@end

View File

@ -0,0 +1,98 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppController.mm
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "___PROJECTNAMEASIDENTIFIER___AppController.h"
#import "cocos2d.h"
#import "EAGLView.h"
#import "___PROJECTNAMEASIDENTIFIER___AppDelegate.h"
@implementation ___PROJECTNAMEASIDENTIFIER___AppController
#pragma mark -
#pragma mark Application lifecycle
// cocos2d application instance
static AppDelegate s_sharedApplication;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
pixelFormat: kEAGLColorFormatRGBA8
depthFormat: 0
preserveBackbuffer: NO
sharegroup:nil
multiSampling:NO
numberOfSamples:0];
[window addSubview: __glView];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];
cocos2d::CCApplication::sharedApplication().run();
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
*/
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
/*
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
}
- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
See also applicationDidEnterBackground:.
*/
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}
- (void)dealloc {
[super dealloc];
}
@end

View File

@ -0,0 +1,106 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppDelegate.cpp
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#include "___PROJECTNAMEASIDENTIFIER___AppDelegate.h"
#include "cocos2d.h"
#include "HelloWorldScene.h"
USING_NS_CC;
AppDelegate::AppDelegate()
{
}
AppDelegate::~AppDelegate()
{
}
bool AppDelegate::initInstance()
{
bool bRet = false;
do
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
// The HelloWorld is designed as HVGA.
CCEGLView * pMainWnd = new CCEGLView();
CC_BREAK_IF(! pMainWnd
|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 320, 480));
#endif // CC_PLATFORM_WIN32
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
// OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here.
#endif // CC_PLATFORM_IOS
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WOPHONE)
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
// The HelloWorld is designed as HVGA.
CCEGLView* pMainWnd = new CCEGLView(this);
CC_BREAK_IF(! pMainWnd || ! pMainWnd->Create(320,480));
#ifndef _TRANZDA_VM_
// on wophone emulator, we copy resources files to Work7/TG3/APP/ folder instead of zip file
cocos2d::CCFileUtils::setResource("HelloWorld.zip");
#endif
#endif // CC_PLATFORM_WOPHONE
bRet = true;
} while (0);
return bRet;
}
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView());
// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
// pDirector->enableRetinaDisplay(true);
// sets landscape mode
pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
// turn on display FPS
pDirector->setDisplayFPS(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
return true;
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground()
{
CCDirector::sharedDirector()->pause();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->resume();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}

View File

@ -0,0 +1,51 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppDelegate.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#ifndef _APP_DELEGATE_H_
#define _APP_DELEGATE_H_
#include "CCApplication.h"
/**
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by CCDirector.
*/
class AppDelegate : private cocos2d::CCApplication
{
public:
AppDelegate();
virtual ~AppDelegate();
/**
@brief Implement for initialize OpenGL instance, set source path, etc...
*/
virtual bool initInstance();
/**
@brief Implement CCDirector and CCScene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/
virtual bool applicationDidFinishLaunching();
/**
@brief The function be called when the application enter background
@param the pointer of the application
*/
virtual void applicationDidEnterBackground();
/**
@brief The function be called when the application enter foreground
@param the pointer of the application
*/
virtual void applicationWillEnterForeground();
};
#endif // _APP_DELEGATE_H_

View File

@ -1,22 +0,0 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppDelegate.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "cocos2d.h"
@class RootViewController;
@interface ___PROJECTNAMEASIDENTIFIER___AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
RootViewController *viewController;
cocos2d::CCXEGLView *view;
}
@property (nonatomic, retain) UIWindow *window;
@end

View File

@ -1,98 +0,0 @@
//
// apptestAppDelegate.m
// apptest
//
// Created by Walzer on 11-1-17.
// Copyright __MyCompanyName__ 2011. All rights reserved.
//
#import "EAGLView.h"
#import "___PROJECTNAMEASIDENTIFIER___AppDelegate.h"
#import "HelloWorldScene.h"
#import "platform/iphone/CCDirectorCaller.h"
@implementation ___PROJECTNAMEASIDENTIFIER___AppDelegate
@synthesize window;
- (void) applicationDidFinishLaunching:(UIApplication*)application
{
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
pixelFormat: kEAGLColorFormatRGBA8
depthFormat: 0
preserveBackbuffer: NO
sharegroup:nil
multiSampling:NO
numberOfSamples:0];
[__glView setMultipleTouchEnabled:YES];
[window addSubview: __glView];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];
// // Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices
// if (! CCDirector::sharedDirector()->enableRetinaDisplay(true)) {
// CCLOG("Retina Display Not supported");
// }
// init director
view = new cocos2d::CCXEGLView();
cocos2d::CCDirector *pDirector = cocos2d::CCDirector::sharedDirector();
pDirector->setOpenGLView(view);
cocos2d::CCDirector::sharedDirector()->setDeviceOrientation(cocos2d::kCCDeviceOrientationLandscapeLeft);
// turn on display FPS
pDirector->setDisplayFPS(true);
// create a scene. it's an autorelease object
cocos2d::CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
// start mainloop
[[CCDirectorCaller sharedDirectorCaller] startMainLoop];
}
- (void)applicationWillResignActive:(UIApplication *)application {
cocos2d::CCDirector::sharedDirector()->pause();
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
cocos2d::CCDirector::sharedDirector()->resume();
}
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
cocos2d::CCDirector::sharedDirector()->purgeCachedData();
}
-(void) applicationDidEnterBackground:(UIApplication*)application {
cocos2d::CCDirector::sharedDirector()->stopAnimation();
}
-(void) applicationWillEnterForeground:(UIApplication*)application {
cocos2d::CCDirector::sharedDirector()->startAnimation();
}
- (void)applicationWillTerminate:(UIApplication *)application {
cocos2d::CCDirector::sharedDirector()->end();
[viewController release];
[window release];
}
- (void)applicationSignificantTimeChange:(UIApplication *)application {
cocos2d::CCDirector::sharedDirector()->setNextDeltaTimeZero(true);
}
- (void)dealloc {
delete view;
[window release];
[super dealloc];
}
@end

View File

@ -1 +1 @@
8eaad60733877a3f984c20062f8e7b3ca4dfdd5c d3596594374bce613ec48e387957b90f74edc9d9

View File

@ -10,7 +10,7 @@
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [NSAutoreleasePool new]; NSAutoreleasePool *pool = [NSAutoreleasePool new];
int retVal = UIApplicationMain(argc, argv, nil, @"___PROJECTNAMEASIDENTIFIER___AppDelegate"); int retVal = UIApplicationMain(argc, argv, nil, @"___PROJECTNAMEASIDENTIFIER___AppController");
[pool release]; [pool release];
return retVal; return retVal;
} }

View File

@ -22,7 +22,7 @@ HelloWorld::HelloWorld()
setIsTouchEnabled( true ); setIsTouchEnabled( true );
setIsAccelerometerEnabled( true ); setIsAccelerometerEnabled( true );
CGSize screenSize = CCDirector::sharedDirector()->getWinSize(); CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
//UXLOG(L"Screen width %0.2f screen height %0.2f",screenSize.width,screenSize.height); //UXLOG(L"Screen width %0.2f screen height %0.2f",screenSize.width,screenSize.height);
// Define the gravity vector. // Define the gravity vector.
@ -84,12 +84,12 @@ HelloWorld::HelloWorld()
CCSpriteBatchNode *mgr = CCSpriteBatchNode::spriteSheetWithFile("blocks.png", 150); CCSpriteBatchNode *mgr = CCSpriteBatchNode::spriteSheetWithFile("blocks.png", 150);
addChild(mgr, 0, kTagSpriteManager); addChild(mgr, 0, kTagSpriteManager);
addNewSpriteWithCoords( CGPointMake(screenSize.width/2, screenSize.height/2) ); addNewSpriteWithCoords( CCPointMake(screenSize.width/2, screenSize.height/2) );
CCLabelTTF *label = CCLabelTTF::labelWithString("Tap screen", "Marker Felt", 32); CCLabelTTF *label = CCLabelTTF::labelWithString("Tap screen", "Marker Felt", 32);
addChild(label, 0); addChild(label, 0);
label->setColor( ccc3(0,0,255) ); label->setColor( ccc3(0,0,255) );
label->setPosition( CGPointMake( screenSize.width/2, screenSize.height-50) ); label->setPosition( CCPointMake( screenSize.width/2, screenSize.height-50) );
schedule( schedule_selector(HelloWorld::tick) ); schedule( schedule_selector(HelloWorld::tick) );
} }
@ -119,7 +119,7 @@ void HelloWorld::draw()
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
} }
void HelloWorld::addNewSpriteWithCoords(CGPoint p) void HelloWorld::addNewSpriteWithCoords(CCPoint p)
{ {
//UXLOG(L"Add sprite %0.2f x %02.f",p.x,p.y); //UXLOG(L"Add sprite %0.2f x %02.f",p.x,p.y);
CCSpriteBatchNode* sheet = (CCSpriteBatchNode*)getChildByTag(kTagSpriteManager); CCSpriteBatchNode* sheet = (CCSpriteBatchNode*)getChildByTag(kTagSpriteManager);
@ -128,10 +128,10 @@ void HelloWorld::addNewSpriteWithCoords(CGPoint p)
//just randomly picking one of the images //just randomly picking one of the images
int idx = (CCRANDOM_0_1() > .5 ? 0:1); int idx = (CCRANDOM_0_1() > .5 ? 0:1);
int idy = (CCRANDOM_0_1() > .5 ? 0:1); int idy = (CCRANDOM_0_1() > .5 ? 0:1);
CCSprite *sprite = sheet->createSpriteWithRect( CGRectMake(32 * idx,32 * idy,32,32)); CCSprite *sprite = sheet->createSpriteWithRect( CCRectMake(32 * idx,32 * idy,32,32));
sheet->addChild(sprite); sheet->addChild(sprite);
sprite->setPosition( CGPointMake( p.x, p.y) ); sprite->setPosition( CCPointMake( p.x, p.y) );
// Define the dynamic body. // Define the dynamic body.
//Set up a 1m squared box in the physics world //Set up a 1m squared box in the physics world
@ -174,16 +174,16 @@ void HelloWorld::tick(ccTime dt)
if (b->GetUserData() != NULL) { if (b->GetUserData() != NULL) {
//Synchronize the AtlasSprites position and rotation with the corresponding body //Synchronize the AtlasSprites position and rotation with the corresponding body
CCSprite* myActor = (CCSprite*)b->GetUserData(); CCSprite* myActor = (CCSprite*)b->GetUserData();
myActor->setPosition( CGPointMake( b->GetPosition().x * PTM_RATIO, b->GetPosition().y * PTM_RATIO) ); myActor->setPosition( CCPointMake( b->GetPosition().x * PTM_RATIO, b->GetPosition().y * PTM_RATIO) );
myActor->setRotation( -1 * CC_RADIANS_TO_DEGREES(b->GetAngle()) ); myActor->setRotation( -1 * CC_RADIANS_TO_DEGREES(b->GetAngle()) );
} }
} }
} }
void HelloWorld::ccTouchesEnded(NSSet* touches, UIEvent* event) void HelloWorld::ccTouchesEnded(CCSet* touches, UIEvent* event)
{ {
//Add a new body/atlas sprite at the touched location //Add a new body/atlas sprite at the touched location
NSSetIterator it; CCSetIterator it;
CCTouch* touch; CCTouch* touch;
for( it = touches->begin(); it != touches->end(); it++) for( it = touches->begin(); it != touches->end(); it++)
@ -193,7 +193,7 @@ void HelloWorld::ccTouchesEnded(NSSet* touches, UIEvent* event)
if(!touch) if(!touch)
break; break;
CGPoint location = touch->locationInView(touch->view()); CCPoint location = touch->locationInView(touch->view());
location = CCDirector::sharedDirector()->convertToGL(location); location = CCDirector::sharedDirector()->convertToGL(location);

View File

@ -21,9 +21,9 @@ public:
static cocos2d::CCScene* scene(); static cocos2d::CCScene* scene();
// adds a new sprite at a given coordinate // adds a new sprite at a given coordinate
void addNewSpriteWithCoords(cocos2d::CGPoint p); void addNewSpriteWithCoords(cocos2d::CCPoint p);
virtual void draw(); virtual void draw();
virtual void ccTouchesEnded(cocos2d::NSSet* touches, cocos2d::UIEvent* event); virtual void ccTouchesEnded(cocos2d::CCSet* touches, cocos2d::UIEvent* event);
void tick(cocos2d::ccTime dt); void tick(cocos2d::ccTime dt);
private: private:

View File

@ -0,0 +1,14 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppController.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
@interface ___PROJECTNAMEASIDENTIFIER___AppController : NSObject <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate,UIApplicationDelegate> {
UIWindow *window;
}
@end

View File

@ -0,0 +1,98 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppController.mm
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "___PROJECTNAMEASIDENTIFIER___AppController.h"
#import "cocos2d.h"
#import "EAGLView.h"
#import "___PROJECTNAMEASIDENTIFIER___AppDelegate.h"
@implementation ___PROJECTNAMEASIDENTIFIER___AppController
#pragma mark -
#pragma mark Application lifecycle
// cocos2d application instance
static AppDelegate s_sharedApplication;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
pixelFormat: kEAGLColorFormatRGBA8
depthFormat: 0
preserveBackbuffer: NO
sharegroup:nil
multiSampling:NO
numberOfSamples:0];
[window addSubview: __glView];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];
cocos2d::CCApplication::sharedApplication().run();
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
*/
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
/*
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
}
- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
See also applicationDidEnterBackground:.
*/
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}
- (void)dealloc {
[super dealloc];
}
@end

View File

@ -0,0 +1,106 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppDelegate.cpp
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#include "___PROJECTNAMEASIDENTIFIER___AppDelegate.h"
#include "cocos2d.h"
#include "HelloWorldScene.h"
USING_NS_CC;
AppDelegate::AppDelegate()
{
}
AppDelegate::~AppDelegate()
{
}
bool AppDelegate::initInstance()
{
bool bRet = false;
do
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
// The HelloWorld is designed as HVGA.
CCEGLView * pMainWnd = new CCEGLView();
CC_BREAK_IF(! pMainWnd
|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 320, 480));
#endif // CC_PLATFORM_WIN32
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
// OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here.
#endif // CC_PLATFORM_IOS
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WOPHONE)
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
// The HelloWorld is designed as HVGA.
CCEGLView* pMainWnd = new CCEGLView(this);
CC_BREAK_IF(! pMainWnd || ! pMainWnd->Create(320,480));
#ifndef _TRANZDA_VM_
// on wophone emulator, we copy resources files to Work7/TG3/APP/ folder instead of zip file
cocos2d::CCFileUtils::setResource("HelloWorld.zip");
#endif
#endif // CC_PLATFORM_WOPHONE
bRet = true;
} while (0);
return bRet;
}
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView());
// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
// pDirector->enableRetinaDisplay(true);
// sets landscape mode
pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
// turn on display FPS
pDirector->setDisplayFPS(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
return true;
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground()
{
CCDirector::sharedDirector()->pause();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->resume();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}

View File

@ -0,0 +1,51 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppDelegate.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#ifndef _APP_DELEGATE_H_
#define _APP_DELEGATE_H_
#include "CCApplication.h"
/**
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by CCDirector.
*/
class AppDelegate : private cocos2d::CCApplication
{
public:
AppDelegate();
virtual ~AppDelegate();
/**
@brief Implement for initialize OpenGL instance, set source path, etc...
*/
virtual bool initInstance();
/**
@brief Implement CCDirector and CCScene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/
virtual bool applicationDidFinishLaunching();
/**
@brief The function be called when the application enter background
@param the pointer of the application
*/
virtual void applicationDidEnterBackground();
/**
@brief The function be called when the application enter foreground
@param the pointer of the application
*/
virtual void applicationWillEnterForeground();
};
#endif // _APP_DELEGATE_H_

View File

@ -1,22 +0,0 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppDelegate.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "cocos2d.h"
@class RootViewController;
@interface ___PROJECTNAMEASIDENTIFIER___AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
RootViewController *viewController;
cocos2d::CCXEGLView *view;
}
@property (nonatomic, retain) UIWindow *window;
@end

View File

@ -1,98 +0,0 @@
//
// apptestAppDelegate.m
// apptest
//
// Created by Walzer on 11-1-17.
// Copyright __MyCompanyName__ 2011. All rights reserved.
//
#import "EAGLView.h"
#import "___PROJECTNAMEASIDENTIFIER___AppDelegate.h"
#import "HelloWorldScene.h"
#import "platform/iphone/CCDirectorCaller.h"
@implementation ___PROJECTNAMEASIDENTIFIER___AppDelegate
@synthesize window;
- (void) applicationDidFinishLaunching:(UIApplication*)application
{
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
pixelFormat: kEAGLColorFormatRGBA8
depthFormat: 0
preserveBackbuffer: NO
sharegroup:nil
multiSampling:NO
numberOfSamples:0];
[__glView setMultipleTouchEnabled:YES];
[window addSubview: __glView];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];
// // Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices
// if (! CCDirector::sharedDirector()->enableRetinaDisplay(true)) {
// CCLOG("Retina Display Not supported");
// }
// init director
view = new cocos2d::CCXEGLView();
cocos2d::CCDirector *pDirector = cocos2d::CCDirector::sharedDirector();
pDirector->setOpenGLView(view);
cocos2d::CCDirector::sharedDirector()->setDeviceOrientation(cocos2d::kCCDeviceOrientationLandscapeLeft);
// turn on display FPS
pDirector->setDisplayFPS(true);
// create a scene. it's an autorelease object
cocos2d::CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
// start mainloop
[[CCDirectorCaller sharedDirectorCaller] startMainLoop];
}
- (void)applicationWillResignActive:(UIApplication *)application {
cocos2d::CCDirector::sharedDirector()->pause();
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
cocos2d::CCDirector::sharedDirector()->resume();
}
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
cocos2d::CCDirector::sharedDirector()->purgeCachedData();
}
-(void) applicationDidEnterBackground:(UIApplication*)application {
cocos2d::CCDirector::sharedDirector()->stopAnimation();
}
-(void) applicationWillEnterForeground:(UIApplication*)application {
cocos2d::CCDirector::sharedDirector()->startAnimation();
}
- (void)applicationWillTerminate:(UIApplication *)application {
cocos2d::CCDirector::sharedDirector()->end();
[viewController release];
[window release];
}
- (void)applicationSignificantTimeChange:(UIApplication *)application {
cocos2d::CCDirector::sharedDirector()->setNextDeltaTimeZero(true);
}
- (void)dealloc {
delete view;
[window release];
[super dealloc];
}
@end

View File

@ -1 +1 @@
86485d992dea618d4513528e3a102cce15955c49 122eb7675b009762b0fd59ff68564bddd57c9d0a

View File

@ -10,7 +10,7 @@
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [NSAutoreleasePool new]; NSAutoreleasePool *pool = [NSAutoreleasePool new];
int retVal = UIApplicationMain(argc, argv, nil, @"___PROJECTNAMEASIDENTIFIER___AppDelegate"); int retVal = UIApplicationMain(argc, argv, nil, @"___PROJECTNAMEASIDENTIFIER___AppController");
[pool release]; [pool release];
return retVal; return retVal;
} }

View File

@ -27,7 +27,7 @@ eachShape(void *ptr, void* unused)
// TIP: cocos2d and chipmunk uses the same struct to store it's position // TIP: cocos2d and chipmunk uses the same struct to store it's position
// chipmunk uses: cpVect, and cocos2d uses CGPoint but in reality the are the same // chipmunk uses: cpVect, and cocos2d uses CGPoint but in reality the are the same
// since v0.7.1 you can mix them if you want. // since v0.7.1 you can mix them if you want.
sprite->setPosition(CGPointMake(body->p.x, body->p.y)); sprite->setPosition(CCPointMake(body->p.x, body->p.y));
sprite->setRotation((float) CC_RADIANS_TO_DEGREES( -body->a )); sprite->setRotation((float) CC_RADIANS_TO_DEGREES( -body->a ));
} }
@ -69,7 +69,7 @@ void HelloWorld::addNewSpriteX(float x, float y)
posx = (posx % 4) * 85; posx = (posx % 4) * 85;
posy = (posy % 3) * 121; posy = (posy % 3) * 121;
CCSprite *sprite = CCSprite::spriteWithBatchNode(batch, CGRectMake(posx, posy, 85, 121)); CCSprite *sprite = CCSprite::spriteWithBatchNode(batch, CCRectMake(posx, posy, 85, 121));
batch->addChild(sprite); batch->addChild(sprite);
sprite->setPosition(ccp(x, y)); sprite->setPosition(ccp(x, y));
@ -104,7 +104,7 @@ bool HelloWorld::init()
{ {
setIsTouchEnabled(true); setIsTouchEnabled(true);
CGSize wins = CCDirector::sharedDirector()->getWinSize(); CCSize wins = CCDirector::sharedDirector()->getWinSize();
cpInitChipmunk(); cpInitChipmunk();
cpBody *staticBody = cpBodyNew(INFINITY, INFINITY); cpBody *staticBody = cpBodyNew(INFINITY, INFINITY);
@ -167,9 +167,9 @@ void HelloWorld::step(ccTime delta)
} }
void HelloWorld::ccTouchesEnded(NSSet *touches, UIEvent *event) void HelloWorld::ccTouchesEnded(CCSet *touches, UIEvent *event)
{ {
NSSetIterator it; CCSetIterator it;
CCTouch *touch; CCTouch *touch;
for (it = touches->begin(); it != touches->end(); it++) { for (it = touches->begin(); it != touches->end(); it++) {
@ -179,7 +179,7 @@ void HelloWorld::ccTouchesEnded(NSSet *touches, UIEvent *event)
break; break;
} }
CGPoint location = touch->locationInView(touch->view()); CCPoint location = touch->locationInView(touch->view());
location = CCDirector::sharedDirector()->convertToGL(location); location = CCDirector::sharedDirector()->convertToGL(location);
addNewSpriteX(location.x, location.y); addNewSpriteX(location.x, location.y);
} }

View File

@ -24,7 +24,7 @@ public:
void step(cocos2d::ccTime dt); void step(cocos2d::ccTime dt);
void addNewSpriteX(float x, float y); void addNewSpriteX(float x, float y);
virtual void onEnter(); virtual void onEnter();
virtual void ccTouchesEnded(cocos2d::NSSet* touches, cocos2d::UIEvent *event); virtual void ccTouchesEnded(cocos2d::CCSet* touches, cocos2d::UIEvent *event);
LAYER_NODE_FUNC(HelloWorld); LAYER_NODE_FUNC(HelloWorld);

View File

@ -0,0 +1,14 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppController.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
@interface ___PROJECTNAMEASIDENTIFIER___AppController : NSObject <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate,UIApplicationDelegate> {
UIWindow *window;
}
@end

View File

@ -0,0 +1,98 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppController.mm
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "___PROJECTNAMEASIDENTIFIER___AppController.h"
#import "cocos2d.h"
#import "EAGLView.h"
#import "___PROJECTNAMEASIDENTIFIER___AppDelegate.h"
@implementation ___PROJECTNAMEASIDENTIFIER___AppController
#pragma mark -
#pragma mark Application lifecycle
// cocos2d application instance
static AppDelegate s_sharedApplication;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
pixelFormat: kEAGLColorFormatRGBA8
depthFormat: 0
preserveBackbuffer: NO
sharegroup:nil
multiSampling:NO
numberOfSamples:0];
[window addSubview: __glView];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];
cocos2d::CCApplication::sharedApplication().run();
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
*/
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
/*
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
}
- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
See also applicationDidEnterBackground:.
*/
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}
- (void)dealloc {
[super dealloc];
}
@end

View File

@ -0,0 +1,106 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppDelegate.cpp
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#include "___PROJECTNAMEASIDENTIFIER___AppDelegate.h"
#include "cocos2d.h"
#include "HelloWorldScene.h"
USING_NS_CC;
AppDelegate::AppDelegate()
{
}
AppDelegate::~AppDelegate()
{
}
bool AppDelegate::initInstance()
{
bool bRet = false;
do
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
// The HelloWorld is designed as HVGA.
CCEGLView * pMainWnd = new CCEGLView();
CC_BREAK_IF(! pMainWnd
|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 320, 480));
#endif // CC_PLATFORM_WIN32
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
// OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here.
#endif // CC_PLATFORM_IOS
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WOPHONE)
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
// The HelloWorld is designed as HVGA.
CCEGLView* pMainWnd = new CCEGLView(this);
CC_BREAK_IF(! pMainWnd || ! pMainWnd->Create(320,480));
#ifndef _TRANZDA_VM_
// on wophone emulator, we copy resources files to Work7/TG3/APP/ folder instead of zip file
cocos2d::CCFileUtils::setResource("HelloWorld.zip");
#endif
#endif // CC_PLATFORM_WOPHONE
bRet = true;
} while (0);
return bRet;
}
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView());
// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
// pDirector->enableRetinaDisplay(true);
// sets landscape mode
pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
// turn on display FPS
pDirector->setDisplayFPS(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
return true;
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground()
{
CCDirector::sharedDirector()->pause();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->resume();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}

View File

@ -0,0 +1,51 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppDelegate.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#ifndef _APP_DELEGATE_H_
#define _APP_DELEGATE_H_
#include "CCApplication.h"
/**
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by CCDirector.
*/
class AppDelegate : private cocos2d::CCApplication
{
public:
AppDelegate();
virtual ~AppDelegate();
/**
@brief Implement for initialize OpenGL instance, set source path, etc...
*/
virtual bool initInstance();
/**
@brief Implement CCDirector and CCScene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/
virtual bool applicationDidFinishLaunching();
/**
@brief The function be called when the application enter background
@param the pointer of the application
*/
virtual void applicationDidEnterBackground();
/**
@brief The function be called when the application enter foreground
@param the pointer of the application
*/
virtual void applicationWillEnterForeground();
};
#endif // _APP_DELEGATE_H_

View File

@ -1,22 +0,0 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppDelegate.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "cocos2d.h"
@class RootViewController;
@interface ___PROJECTNAMEASIDENTIFIER___AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
RootViewController *viewController;
cocos2d::CCXEGLView *view;
}
@property (nonatomic, retain) UIWindow *window;
@end

View File

@ -1,98 +0,0 @@
//
// apptestAppDelegate.m
// apptest
//
// Created by Walzer on 11-1-17.
// Copyright __MyCompanyName__ 2011. All rights reserved.
//
#import "EAGLView.h"
#import "___PROJECTNAMEASIDENTIFIER___AppDelegate.h"
#import "HelloWorldScene.h"
#import "platform/iphone/CCDirectorCaller.h"
@implementation ___PROJECTNAMEASIDENTIFIER___AppDelegate
@synthesize window;
- (void) applicationDidFinishLaunching:(UIApplication*)application
{
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
pixelFormat: kEAGLColorFormatRGBA8
depthFormat: 0
preserveBackbuffer: NO
sharegroup:nil
multiSampling:NO
numberOfSamples:0];
[__glView setMultipleTouchEnabled:YES];
[window addSubview: __glView];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];
// // Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices
// if (! CCDirector::sharedDirector()->enableRetinaDisplay(true)) {
// CCLOG("Retina Display Not supported");
// }
// init director
view = new cocos2d::CCXEGLView();
cocos2d::CCDirector *pDirector = cocos2d::CCDirector::sharedDirector();
pDirector->setOpenGLView(view);
cocos2d::CCDirector::sharedDirector()->setDeviceOrientation(cocos2d::kCCDeviceOrientationLandscapeLeft);
// turn on display FPS
pDirector->setDisplayFPS(true);
// create a scene. it's an autorelease object
cocos2d::CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
// start mainloop
[[CCDirectorCaller sharedDirectorCaller] startMainLoop];
}
- (void)applicationWillResignActive:(UIApplication *)application {
cocos2d::CCDirector::sharedDirector()->pause();
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
cocos2d::CCDirector::sharedDirector()->resume();
}
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
cocos2d::CCDirector::sharedDirector()->purgeCachedData();
}
-(void) applicationDidEnterBackground:(UIApplication*)application {
cocos2d::CCDirector::sharedDirector()->stopAnimation();
}
-(void) applicationWillEnterForeground:(UIApplication*)application {
cocos2d::CCDirector::sharedDirector()->startAnimation();
}
- (void)applicationWillTerminate:(UIApplication *)application {
cocos2d::CCDirector::sharedDirector()->end();
[viewController release];
[window release];
}
- (void)applicationSignificantTimeChange:(UIApplication *)application {
cocos2d::CCDirector::sharedDirector()->setNextDeltaTimeZero(true);
}
- (void)dealloc {
delete view;
[window release];
[super dealloc];
}
@end

View File

@ -1 +1 @@
31d059bae90b466d226532d68266be129882eb4d c61d7da24a3e6a4284e796e3ece68928ef2cca59

View File

@ -10,7 +10,7 @@
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [NSAutoreleasePool new]; NSAutoreleasePool *pool = [NSAutoreleasePool new];
int retVal = UIApplicationMain(argc, argv, nil, @"___PROJECTNAMEASIDENTIFIER___AppDelegate"); int retVal = UIApplicationMain(argc, argv, nil, @"___PROJECTNAMEASIDENTIFIER___AppController");
[pool release]; [pool release];
return retVal; return retVal;
} }