Skip to content

Commit

Permalink
[airplay] fixed cocos2d#480, add template for airplay
Browse files Browse the repository at this point in the history
  • Loading branch information
Walzer committed May 3, 2011
1 parent bc3cec6 commit fd55795
Show file tree
Hide file tree
Showing 10 changed files with 432 additions and 0 deletions.
192 changes: 192 additions & 0 deletions template/airplay/Data/Fonts/arial16.fnt

Large diffs are not rendered by default.

Binary file added template/airplay/Data/Fonts/arial16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions template/airplay/README.txt
@@ -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

65 changes: 65 additions & 0 deletions template/airplay/Source/AppDelegate.cpp
@@ -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();
}
43 changes: 43 additions & 0 deletions template/airplay/Source/AppDelegate.h
@@ -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_

16 changes: 16 additions & 0 deletions template/airplay/Source/Main.cpp
@@ -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;
}
4 changes: 4 additions & 0 deletions template/airplay/Source/Main.h
@@ -0,0 +1,4 @@
#ifndef MAIN_H
#define MAIN_H

#endif
41 changes: 41 additions & 0 deletions template/airplay/Source/MyScene.cpp
@@ -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();
}
22 changes: 22 additions & 0 deletions template/airplay/Source/MyScene.h
@@ -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__
45 changes: 45 additions & 0 deletions template/airplay/___PROJECTNAME___.mkb
@@ -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"
}


0 comments on commit fd55795

Please sign in to comment.