[iphone] fixed #302 template for xcode

This commit is contained in:
walzer 2011-01-17 17:03:48 +08:00
parent ad5ee3c9f6
commit b574a47b9e
41 changed files with 381 additions and 704 deletions

View File

@ -1,86 +0,0 @@
//
// AppDelegate.cpp
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#include "cocos2d.h"
#include "AppDelegate.h"
#include "HelloWorldScene.h"
using namespace cocos2d;
AppDelegate::AppDelegate()
:m_pMainWnd(NULL)
{
}
AppDelegate::~AppDelegate()
{
#if defined(CCX_PLATFORM_WIN32)
CCX_SAFE_DELETE(m_pMainWnd);
#endif
}
bool AppDelegate::applicationDidFinishLaunching()
{
// init the window
#if defined(CCX_PLATFORM_UPHONE)
if (!(m_pMainWnd = new CCXEGLView(this)) ||
! m_pMainWnd->Create(&TRectangle(0,0,GetScreenWidth(),GetScreenHeight())))
#elif defined(CCX_PLATFORM_WIN32)
if (! (m_pMainWnd = new CCXEGLView()) ||
! m_pMainWnd->Create(L"HelloWorld", 320, 480))
#elif defined(CCX_PLATFORM_IPHONE)
if (! (m_pMainWnd = new CCXEGLView() ) )
#elif defined(CCX_PLATFORM_ANDROID)
if (!(m_pMainWnd = CCDirector::sharedDirector()->getOpenGLView()))
#else
#error
#endif
{
delete m_pMainWnd;
return false;
}
// init director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(m_pMainWnd);
// sets landscape mode
pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
// turn on display FPS
pDirector->setDisplayFPS(true);
// 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

@ -1,30 +0,0 @@
//
// AppDelegate.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#ifndef _APP_DELEGATE_H_
#define _APP_DELEGATE_H_
#include "CCXApplication.h"
#include "CCXEGLView.h"
class AppDelegate : public cocos2d::CCXApplication
{
public:
AppDelegate();
~AppDelegate();
virtual bool applicationDidFinishLaunching();
virtual void applicationDidEnterBackground();
virtual void applicationWillEnterForeground();
protected:
cocos2d::CCXEGLView * m_pMainWnd;
};
#endif // _APP_DELEGATE_H_

View File

View File

View File

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

View File

@ -1,105 +0,0 @@
//
// ___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 "AppDelegate.h"
@implementation ___PROJECTNAMEASIDENTIFIER___AppController
#pragma mark -
#pragma mark Application lifecycle
- (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];
[__glView setMultipleTouchEnabled:YES];
[window addSubview: __glView];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];
AppDelegate app;
app.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 {
[window release];
[super dealloc];
}
@end
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
UIApplicationMain(argc, argv, nil, @"___PROJECTNAMEASIDENTIFIER___AppController");
[pool release];
return 0;
}

0
template/ios_mac/cocos2d-x_app/LICENSE.cocos2d-x Normal file → Executable file
View File

View File

@ -0,0 +1,22 @@
//
// ___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

@ -0,0 +1,98 @@
//
// 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 @@
31bcb75279b81b476380e0200382ab0d92d29632
8eaad60733877a3f984c20062f8e7b3ca4dfdd5c

View File

@ -0,0 +1,16 @@
//
// main.m
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
int retVal = UIApplicationMain(argc, argv, nil, @"___PROJECTNAMEASIDENTIFIER___AppDelegate");
[pool release];
return retVal;
}

View File

@ -1,88 +0,0 @@
//
// AppDelegate.cpp
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#include "cocos2d.h"
#include "AppDelegate.h"
#include "HelloWorldScene.h"
using namespace cocos2d;
AppDelegate::AppDelegate()
:m_pMainWnd(NULL)
{
}
AppDelegate::~AppDelegate()
{
#if defined(CCX_PLATFORM_WIN32)
CCX_SAFE_DELETE(m_pMainWnd);
#endif
}
bool AppDelegate::applicationDidFinishLaunching()
{
// init the window
#if defined(CCX_PLATFORM_UPHONE)
if (!(m_pMainWnd = new CCXEGLView(this)) ||
! m_pMainWnd->Create(&TRectangle(0,0,GetScreenWidth(),GetScreenHeight())))
#elif defined(CCX_PLATFORM_WIN32)
if (! (m_pMainWnd = new CCXEGLView()) ||
! m_pMainWnd->Create(L"HelloWorld", 320, 480))
#elif defined(CCX_PLATFORM_IPHONE)
if (! (m_pMainWnd = new CCXEGLView() ) )
#elif defined(CCX_PLATFORM_ANDROID)
if (!(m_pMainWnd = CCDirector::sharedDirector()->getOpenGLView()))
#else
#error
#endif
{
delete m_pMainWnd;
return false;
}
// init director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(m_pMainWnd);
// sets landscape mode
pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
// turn on display FPS
pDirector->setDisplayFPS(true);
// 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

@ -1,32 +0,0 @@
//
// AppDelegate.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#ifndef _APP_DELEGATE_H_
#define _APP_DELEGATE_H_
#include "CCXApplication.h"
#include "CCXEGLView.h"
class AppDelegate : public cocos2d::CCXApplication
{
public:
AppDelegate();
~AppDelegate();
virtual bool applicationDidFinishLaunching();
virtual void applicationDidEnterBackground();
virtual void applicationWillEnterForeground();
protected:
cocos2d::CCXEGLView * m_pMainWnd;
};
#endif // _APP_DELEGATE_H_

View File

View File

View File

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

View File

@ -1,98 +0,0 @@
//
// ___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 "AppDelegate.h"
@implementation ___PROJECTNAMEASIDENTIFIER___AppController
#pragma mark -
#pragma mark Application lifecycle
- (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];
[__glView setMultipleTouchEnabled:YES];
[window addSubview: __glView];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];
AppDelegate app;
app.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 {
[window release];
[super dealloc];
}
@end

0
template/ios_mac/cocos2d-x_box2d_app/LICENSE.box2d Normal file → Executable file
View File

0
template/ios_mac/cocos2d-x_box2d_app/LICENSE.cocos2d-x Normal file → Executable file
View File

View File

@ -0,0 +1,22 @@
//
// ___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

@ -0,0 +1,98 @@
//
// 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 @@
780bee0827659474dfe7df01ccbb867aee6fbec2
86485d992dea618d4513528e3a102cce15955c49

2
template/ios_mac/cocos2d-x_box2d_app/main.m Normal file → Executable file
View File

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

View File

@ -1,88 +0,0 @@
//
// AppDelegate.cpp
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#include "cocos2d.h"
#include "AppDelegate.h"
#include "HelloWorldScene.h"
using namespace cocos2d;
AppDelegate::AppDelegate()
:m_pMainWnd(NULL)
{
}
AppDelegate::~AppDelegate()
{
#if defined(CCX_PLATFORM_WIN32)
CCX_SAFE_DELETE(m_pMainWnd);
#endif
}
bool AppDelegate::applicationDidFinishLaunching()
{
// init the window
#if defined(CCX_PLATFORM_UPHONE)
if (!(m_pMainWnd = new CCXEGLView(this)) ||
! m_pMainWnd->Create(&TRectangle(0,0,GetScreenWidth(),GetScreenHeight())))
#elif defined(CCX_PLATFORM_WIN32)
if (! (m_pMainWnd = new CCXEGLView()) ||
! m_pMainWnd->Create(L"HelloWorld", 320, 480))
#elif defined(CCX_PLATFORM_IPHONE)
if (! (m_pMainWnd = new CCXEGLView() ) )
#elif defined(CCX_PLATFORM_ANDROID)
if (!(m_pMainWnd = CCDirector::sharedDirector()->getOpenGLView()))
#else
#error
#endif
{
delete m_pMainWnd;
return false;
}
// init director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(m_pMainWnd);
// sets landscape mode
pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
// turn on display FPS
pDirector->setDisplayFPS(true);
// 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

@ -1,32 +0,0 @@
//
// AppDelegate.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#ifndef _APP_DELEGATE_H_
#define _APP_DELEGATE_H_
#include "CCXApplication.h"
#include "CCXEGLView.h"
class AppDelegate : public cocos2d::CCXApplication
{
public:
AppDelegate();
~AppDelegate();
virtual bool applicationDidFinishLaunching();
virtual void applicationDidEnterBackground();
virtual void applicationWillEnterForeground();
protected:
cocos2d::CCXEGLView * m_pMainWnd;
};
#endif // _APP_DELEGATE_H_

View File

View File

View File

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

View File

@ -1,98 +0,0 @@
//
// ___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 "AppDelegate.h"
@implementation ___PROJECTNAMEASIDENTIFIER___AppController
#pragma mark -
#pragma mark Application lifecycle
- (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];
[__glView setMultipleTouchEnabled:YES];
[window addSubview: __glView];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];
AppDelegate app;
app.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 {
[window release];
[super dealloc];
}
@end

View File

View File

View File

@ -0,0 +1,22 @@
//
// ___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

@ -0,0 +1,98 @@
//
// 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 @@
e4e97e44345dfc7a71318d585af4d4ea81f38fcd
31d059bae90b466d226532d68266be129882eb4d

2
template/ios_mac/cocos2d-x_chipmunk_app/main.m Normal file → Executable file
View File

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