forked from cocos2d/cocos2d-x
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[airplay] fixed cocos2d#480, add template for airplay
- Loading branch information
Walzer
committed
May 3, 2011
1 parent
bc3cec6
commit fd55795
Showing
10 changed files
with
432 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,4 @@ | ||
order that would edit the paths, add modules or files you need to edit the main project file: ___PROJECTNAME___.mkb | ||
|
||
order that would set up options Airplay SDK for this project, you must edit the file: /Data/app.icf | ||
|
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,65 @@ | ||
#include "AppDelegate.h" | ||
|
||
#include "cocos2d.h" | ||
#include "MyScene.h" | ||
|
||
USING_NS_CC; | ||
|
||
AppDelegate::AppDelegate() | ||
{ | ||
|
||
} | ||
|
||
AppDelegate::~AppDelegate() | ||
{ | ||
} | ||
|
||
bool AppDelegate::initInstance() | ||
{ | ||
return true; | ||
} | ||
|
||
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 = MyScene::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(); | ||
} |
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,43 @@ | ||
#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_ | ||
|
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 @@ | ||
// Application main file. | ||
|
||
#include "Main.h" | ||
#include "AppDelegate.h" | ||
|
||
|
||
int main() | ||
{ | ||
AppDelegate* app; | ||
int nRet = 0; | ||
|
||
app = new AppDelegate; | ||
nRet = cocos2d::CCApplication::sharedApplication().Run();; | ||
delete app; | ||
return nRet; | ||
} |
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,4 @@ | ||
#ifndef MAIN_H | ||
#define MAIN_H | ||
|
||
#endif |
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,41 @@ | ||
#include "MyScene.h" | ||
|
||
USING_NS_CC; | ||
|
||
CCScene* MyScene::scene() | ||
{ | ||
// 'scene' is an autorelease object | ||
CCScene *scene = CCScene::node(); | ||
|
||
// 'layer' is an autorelease object | ||
MyScene *layer = MyScene::node(); | ||
|
||
// add layer as a child to scene | ||
scene->addChild(layer); | ||
|
||
// return the scene | ||
return scene; | ||
} | ||
|
||
// on "init" you need to initialize your instance | ||
bool MyScene::init() | ||
{ | ||
////////////////////////////// | ||
// 1. super init first | ||
if ( !CCLayer::init() ) | ||
{ | ||
return false; | ||
} | ||
|
||
////////////////////////////// | ||
// 2. add your codes below... | ||
|
||
|
||
////////////////////////////// | ||
return true; | ||
} | ||
|
||
void MyScene::menuCloseCallback(CCObject* pSender) | ||
{ | ||
CCDirector::sharedDirector()->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,22 @@ | ||
#ifndef __MY_SCENE_H__ | ||
#define __MY_SCENE_H__ | ||
|
||
#include "cocos2d.h" | ||
|
||
class MyScene : public cocos2d::CCLayer | ||
{ | ||
public: | ||
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone | ||
virtual bool init(); | ||
|
||
// there's no 'id' in cpp, so we recommand to return the exactly class pointer | ||
static cocos2d::CCScene* scene(); | ||
|
||
// a selector callback | ||
virtual void menuCloseCallback(CCObject* pSender); | ||
|
||
// implement the "static node()" method manually | ||
LAYER_NODE_FUNC(MyScene); | ||
}; | ||
|
||
#endif // __HELLOWORLD_SCENE_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,45 @@ | ||
options | ||
{ | ||
# path to data of current game | ||
|
||
s3e-data-dir="Data" | ||
|
||
# paths to modules of cocos2d-x - uncomment and customize if you need additional modules | ||
|
||
module_path="../../cocos2dx/proj.airplay/" | ||
# module_path="../../Box2D/proj.airplay/" | ||
# module_path="../../chipmunk/proj.airplay/" | ||
# module_path="../../CocosDenshion/proj.airplay/" | ||
|
||
} | ||
|
||
includepaths | ||
{ | ||
.. | ||
} | ||
subprojects | ||
{ | ||
# required module of Airplay SDK | ||
|
||
IwGL | ||
|
||
# required module of cocos2d-x | ||
|
||
cocos2dx | ||
|
||
# additional modules of cocos2d-x - uncomment if necessary | ||
|
||
# Box2D | ||
# chipmunk | ||
# CocosDenshion | ||
} | ||
|
||
files | ||
{ | ||
[Source] | ||
("Source") | ||
"*.h" | ||
"*.cpp" | ||
} | ||
|
||
|