issue #2129: Removing CC prefix for template.

This commit is contained in:
James Chen 2013-06-20 22:18:43 +08:00
parent de0e683014
commit d1bd34fd08
45 changed files with 250 additions and 250 deletions

View File

@ -17,8 +17,8 @@ AppDelegate::~AppDelegate()
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
Director *pDirector = Director::sharedDirector();
pDirector->setOpenGLView(EGLView::sharedOpenGLView());
// turn on display FPS
pDirector->setDisplayStats(true);
@ -27,7 +27,7 @@ bool AppDelegate::applicationDidFinishLaunching()
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene();
Scene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
@ -38,7 +38,7 @@ bool AppDelegate::applicationDidFinishLaunching()
// 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();
Director::sharedDirector()->pause();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
@ -47,7 +47,7 @@ void AppDelegate::applicationDidEnterBackground()
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->resume();
Director::sharedDirector()->resume();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();

View File

@ -6,16 +6,16 @@
/**
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by CCDirector.
The reason for implement as private inheritance is to hide some interface call by Director.
*/
class AppDelegate : private cocos2d::CCApplication
class AppDelegate : private cocos2d::Application
{
public:
AppDelegate();
virtual ~AppDelegate();
/**
@brief Implement CCDirector and CCScene init code here.
@brief Implement Director and Scene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/

View File

@ -4,10 +4,10 @@
using namespace cocos2d;
using namespace CocosDenshion;
CCScene* HelloWorld::scene()
Scene* HelloWorld::scene()
{
// 'scene' is an autorelease object
CCScene *scene = CCScene::create();
Scene *scene = Scene::create();
// 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::create();
@ -24,7 +24,7 @@ bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
if ( !Layer::init() )
{
return false;
}
@ -34,16 +34,16 @@ bool HelloWorld::init()
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
MenuItemImage *pCloseItem = MenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback) );
pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );
pCloseItem->setPosition( ccp(Director::sharedDirector()->getWinSize().width - 20, 20) );
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition( CCPointZero );
Menu* pMenu = Menu::create(pCloseItem, NULL);
pMenu->setPosition( PointZero );
this->addChild(pMenu, 1);
/////////////////////////////
@ -51,10 +51,10 @@ bool HelloWorld::init()
// add a label shows "Hello World"
// create and initialize a label
CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Thonburi", 34);
LabelTTF* pLabel = LabelTTF::create("Hello World", "Thonburi", 34);
// ask director the window size
CCSize size = CCDirector::sharedDirector()->getWinSize();
Size size = Director::sharedDirector()->getWinSize();
// position the label on the center of the screen
pLabel->setPosition( ccp(size.width / 2, size.height - 20) );
@ -63,7 +63,7 @@ bool HelloWorld::init()
this->addChild(pLabel, 1);
// add "HelloWorld" splash screen"
CCSprite* pSprite = CCSprite::create("HelloWorld.png");
Sprite* pSprite = Sprite::create("HelloWorld.png");
// position the sprite on the center of the screen
pSprite->setPosition( ccp(size.width/2, size.height/2) );
@ -74,9 +74,9 @@ bool HelloWorld::init()
return true;
}
void HelloWorld::menuCloseCallback(CCObject* pSender)
void HelloWorld::menuCloseCallback(Object* pSender)
{
CCDirector::sharedDirector()->end();
Director::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);

View File

@ -3,17 +3,17 @@
#include "cocos2d.h"
class HelloWorld : public cocos2d::CCLayer
class HelloWorld : public cocos2d::Layer
{
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();
static cocos2d::Scene* scene();
// a selector callback
void menuCloseCallback(CCObject* pSender);
void menuCloseCallback(Object* pSender);
// implement the "static node()" method manually
CREATE_FUNC(HelloWorld);

View File

@ -13,8 +13,8 @@ AppDelegate::~AppDelegate()
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
CCDirector* pDirector = CCDirector::sharedDirector();
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
Director* pDirector = Director::sharedDirector();
EGLView* pEGLView = EGLView::sharedOpenGLView();
pDirector->setOpenGLView(pEGLView);
@ -25,7 +25,7 @@ bool AppDelegate::applicationDidFinishLaunching() {
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene();
Scene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
@ -35,7 +35,7 @@ bool AppDelegate::applicationDidFinishLaunching() {
// 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()->stopAnimation();
Director::sharedDirector()->stopAnimation();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
@ -43,7 +43,7 @@ void AppDelegate::applicationDidEnterBackground() {
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() {
CCDirector::sharedDirector()->startAnimation();
Director::sharedDirector()->startAnimation();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();

View File

@ -6,16 +6,16 @@
/**
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by CCDirector.
The reason for implement as private inheritance is to hide some interface call by Director.
*/
class AppDelegate : private cocos2d::CCApplication
class AppDelegate : private cocos2d::Application
{
public:
AppDelegate();
virtual ~AppDelegate();
/**
@brief Implement CCDirector and CCScene init code here.
@brief Implement Director and Scene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/

View File

@ -2,10 +2,10 @@
USING_NS_CC;
CCScene* HelloWorld::scene()
Scene* HelloWorld::scene()
{
// 'scene' is an autorelease object
CCScene *scene = CCScene::create();
Scene *scene = Scene::create();
// 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::create();
@ -22,20 +22,20 @@ bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
if ( !Layer::init() )
{
return false;
}
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
Size visibleSize = Director::sharedDirector()->getVisibleSize();
Point origin = Director::sharedDirector()->getVisibleOrigin();
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
MenuItemImage *pCloseItem = MenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
@ -45,8 +45,8 @@ bool HelloWorld::init()
origin.y + pCloseItem->getContentSize().height/2));
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition(CCPointZero);
Menu* pMenu = Menu::create(pCloseItem, NULL);
pMenu->setPosition(PointZero);
this->addChild(pMenu, 1);
/////////////////////////////
@ -55,7 +55,7 @@ bool HelloWorld::init()
// add a label shows "Hello World"
// create and initialize a label
CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24);
LabelTTF* pLabel = LabelTTF::create("Hello World", "Arial", 24);
// position the label on the center of the screen
pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
@ -65,7 +65,7 @@ bool HelloWorld::init()
this->addChild(pLabel, 1);
// add "HelloWorld" splash screen"
CCSprite* pSprite = CCSprite::create("HelloWorld.png");
Sprite* pSprite = Sprite::create("HelloWorld.png");
// position the sprite on the center of the screen
pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
@ -77,9 +77,9 @@ bool HelloWorld::init()
}
void HelloWorld::menuCloseCallback(CCObject* pSender)
void HelloWorld::menuCloseCallback(Object* pSender)
{
CCDirector::sharedDirector()->end();
Director::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);

View File

@ -3,17 +3,17 @@
#include "cocos2d.h"
class HelloWorld : public cocos2d::CCLayer
class HelloWorld : public cocos2d::Layer
{
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 recommend returning the class instance pointer
static cocos2d::CCScene* scene();
static cocos2d::Scene* scene();
// a selector callback
void menuCloseCallback(CCObject* pSender);
void menuCloseCallback(Object* pSender);
// implement the "static node()" method manually
CREATE_FUNC(HelloWorld);

View File

@ -22,13 +22,13 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
{
if (!CCDirector::sharedDirector()->getOpenGLView())
if (!Director::sharedDirector()->getOpenGLView())
{
CCEGLView *view = CCEGLView::sharedOpenGLView();
EGLView *view = EGLView::sharedOpenGLView();
view->setFrameSize(w, h);
AppDelegate *pAppDelegate = new AppDelegate();
CCApplication::sharedApplication()->run();
Application::sharedApplication()->run();
}
/*
else
@ -36,10 +36,10 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
ccDrawInit();
ccGLInvalidateStateCache();
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
CCTextureCache::reloadAllTextures();
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
CCDirector::sharedDirector()->setGLDefaultValues();
ShaderCache::sharedShaderCache()->reloadDefaultShaders();
TextureCache::reloadAllTextures();
NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::sharedDirector()->setGLDefaultValues();
}
*/
}

View File

@ -23,8 +23,8 @@ int main(int argc, char **argv)
height = 600;
}
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
EGLView* eglView = EGLView::sharedOpenGLView();
eglView->setFrameSize(width, height);
return CCApplication::sharedApplication()->run();
return Application::sharedApplication()->run();
}

View File

@ -49,7 +49,7 @@ static AppDelegate s_sharedApplication;
[[UIApplication sharedApplication] setStatusBarHidden:true];
cocos2d::CCApplication::sharedApplication()->run();
cocos2d::Application::sharedApplication()->run();
return YES;
}
@ -60,14 +60,14 @@ static AppDelegate s_sharedApplication;
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.
*/
cocos2d::CCDirector::sharedDirector()->pause();
cocos2d::Director::sharedDirector()->pause();
}
- (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.
*/
cocos2d::CCDirector::sharedDirector()->resume();
cocos2d::Director::sharedDirector()->resume();
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
@ -75,14 +75,14 @@ static AppDelegate s_sharedApplication;
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.
*/
cocos2d::CCApplication::sharedApplication()->applicationDidEnterBackground();
cocos2d::Application::sharedApplication()->applicationDidEnterBackground();
}
- (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.
*/
cocos2d::CCApplication::sharedApplication()->applicationWillEnterForeground();
cocos2d::Application::sharedApplication()->applicationWillEnterForeground();
}
- (void)applicationWillTerminate:(UIApplication *)application {

View File

@ -13,7 +13,7 @@ int main(int argc, char **argv)
{
// create the application instance
AppDelegate app;
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
EGLView* eglView = EGLView::sharedOpenGLView();
eglView->setFrameSize(800, 480);
return CCApplication::sharedApplication()->run();
return Application::sharedApplication()->run();
}

View File

@ -62,7 +62,7 @@
[window makeKeyAndOrderFront:self];
[window setAcceptsMouseMovedEvents:NO];
cocos2d::CCApplication::sharedApplication()->run();
cocos2d::Application::sharedApplication()->run();
}
-(BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication
@ -72,7 +72,7 @@
-(void) dealloc
{
cocos2d::CCDirector::sharedDirector()->end();
cocos2d::Director::sharedDirector()->end();
[super dealloc];
}

View File

@ -15,5 +15,5 @@ int main()
{
AppDelegate app;
return cocos2d::CCApplication::sharedApplication()->Run();
return cocos2d::Application::sharedApplication()->Run();
}

View File

@ -14,8 +14,8 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
// create the application instance
AppDelegate app;
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
EGLView* eglView = EGLView::sharedOpenGLView();
eglView->setViewName("HelloCpp");
eglView->setFrameSize(480, 320);
return CCApplication::sharedApplication()->run();
return Application::sharedApplication()->run();
}

View File

@ -23,14 +23,14 @@ AppDelegate::AppDelegate()
AppDelegate::~AppDelegate()
{
CCScriptEngineManager::purgeSharedManager();
ScriptEngineManager::purgeSharedManager();
}
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
Director *pDirector = Director::sharedDirector();
pDirector->setOpenGLView(EGLView::sharedOpenGLView());
// turn on display FPS
pDirector->setDisplayStats(true);
@ -52,8 +52,8 @@ bool AppDelegate::applicationDidFinishLaunching()
sc->start();
CCScriptEngineProtocol *pEngine = ScriptingCore::getInstance();
CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
ScriptEngineProtocol *pEngine = ScriptingCore::getInstance();
ScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
ScriptingCore::getInstance()->runScript("main.js");
return true;
@ -63,11 +63,11 @@ void handle_signal(int signal) {
static int internal_state = 0;
ScriptingCore* sc = ScriptingCore::getInstance();
// should start everything back
CCDirector* director = CCDirector::sharedDirector();
Director* director = Director::sharedDirector();
if (director->getRunningScene()) {
director->popToRootScene();
} else {
CCPoolManager::sharedPoolManager()->finalize();
PoolManager::sharedPoolManager()->finalize();
if (internal_state == 0) {
//sc->dumpRoot(NULL, 0, NULL);
sc->start();
@ -82,7 +82,7 @@ void handle_signal(int signal) {
// 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()->stopAnimation();
Director::sharedDirector()->stopAnimation();
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
SimpleAudioEngine::sharedEngine()->pauseAllEffects();
}
@ -90,7 +90,7 @@ void AppDelegate::applicationDidEnterBackground()
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->startAnimation();
Director::sharedDirector()->startAnimation();
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
SimpleAudioEngine::sharedEngine()->resumeAllEffects();
}

View File

@ -13,16 +13,16 @@
/**
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by CCDirector.
The reason for implement as private inheritance is to hide some interface call by Director.
*/
class AppDelegate : private cocos2d::CCApplication
class AppDelegate : private cocos2d::Application
{
public:
AppDelegate();
virtual ~AppDelegate();
/**
@brief Implement CCDirector and CCScene init code here.
@brief Implement Director and Scene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/

View File

@ -22,23 +22,23 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
{
if (!CCDirector::sharedDirector()->getOpenGLView())
if (!Director::sharedDirector()->getOpenGLView())
{
CCEGLView *view = CCEGLView::sharedOpenGLView();
EGLView *view = EGLView::sharedOpenGLView();
view->setFrameSize(w, h);
AppDelegate *pAppDelegate = new AppDelegate();
CCApplication::sharedApplication()->run();
Application::sharedApplication()->run();
}
else
{
ccDrawInit();
ccGLInvalidateStateCache();
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
CCTextureCache::reloadAllTextures();
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
CCDirector::sharedDirector()->setGLDefaultValues();
ShaderCache::sharedShaderCache()->reloadDefaultShaders();
TextureCache::reloadAllTextures();
NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::sharedDirector()->setGLDefaultValues();
}
}

View File

@ -52,7 +52,7 @@ static AppDelegate s_sharedApplication;
[[UIApplication sharedApplication] setStatusBarHidden: YES];
cocos2d::CCApplication::sharedApplication()->run();
cocos2d::Application::sharedApplication()->run();
return YES;
}
@ -62,14 +62,14 @@ static AppDelegate s_sharedApplication;
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.
*/
cocos2d::CCDirector::sharedDirector()->pause();
cocos2d::Director::sharedDirector()->pause();
}
- (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.
*/
cocos2d::CCDirector::sharedDirector()->resume();
cocos2d::Director::sharedDirector()->resume();
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
@ -77,14 +77,14 @@ static AppDelegate s_sharedApplication;
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.
*/
cocos2d::CCApplication::sharedApplication()->applicationDidEnterBackground();
cocos2d::Application::sharedApplication()->applicationDidEnterBackground();
}
- (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.
*/
cocos2d::CCApplication::sharedApplication()->applicationWillEnterForeground();
cocos2d::Application::sharedApplication()->applicationWillEnterForeground();
}
- (void)applicationWillTerminate:(UIApplication *)application {
@ -102,7 +102,7 @@ static AppDelegate s_sharedApplication;
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
cocos2d::CCDirector::sharedDirector()->purgeCachedData();
cocos2d::Director::sharedDirector()->purgeCachedData();
}

View File

@ -24,11 +24,11 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
// create the application instance
AppDelegate app;
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
EGLView* eglView = EGLView::sharedOpenGLView();
eglView->setViewName("HelloJavascript");
eglView->setFrameSize(480, 320);
int ret = CCApplication::sharedApplication()->run();
int ret = Application::sharedApplication()->run();
#ifdef USE_WIN32_CONSOLE
FreeConsole();

View File

@ -24,8 +24,8 @@ AppDelegate::~AppDelegate()
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
Director *pDirector = Director::sharedDirector();
pDirector->setOpenGLView(EGLView::sharedOpenGLView());
// turn on display FPS
pDirector->setDisplayStats(true);
@ -34,10 +34,10 @@ bool AppDelegate::applicationDidFinishLaunching()
pDirector->setAnimationInterval(1.0 / 60);
// register lua engine
CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
LuaEngine* pEngine = LuaEngine::defaultEngine();
ScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
CCLuaStack *pStack = pEngine->getLuaStack();
LuaStack *pStack = pEngine->getLuaStack();
lua_State *tolua_s = pStack->getLuaState();
tolua_extensions_ccb_open(tolua_s);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
@ -46,7 +46,7 @@ bool AppDelegate::applicationDidFinishLaunching()
tolua_web_socket_open(tolua_s);
#endif
std::string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("hello.lua");
std::string path = FileUtils::sharedFileUtils()->fullPathForFilename("hello.lua");
pEngine->executeScriptFile(path.c_str());
return true;
@ -55,7 +55,7 @@ bool AppDelegate::applicationDidFinishLaunching()
// 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()->stopAnimation();
Director::sharedDirector()->stopAnimation();
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
@ -63,7 +63,7 @@ void AppDelegate::applicationDidEnterBackground()
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->startAnimation();
Director::sharedDirector()->startAnimation();
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}

View File

@ -6,16 +6,16 @@
/**
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by CCDirector.
The reason for implement as private inheritance is to hide some interface call by Director.
*/
class AppDelegate : private cocos2d::CCApplication
class AppDelegate : private cocos2d::Application
{
public:
AppDelegate();
virtual ~AppDelegate();
/**
@brief Implement CCDirector and CCScene init code here.
@brief Implement Director and Scene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/

View File

@ -22,23 +22,23 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
{
if (!CCDirector::sharedDirector()->getOpenGLView())
if (!Director::sharedDirector()->getOpenGLView())
{
CCEGLView *view = CCEGLView::sharedOpenGLView();
EGLView *view = EGLView::sharedOpenGLView();
view->setFrameSize(w, h);
AppDelegate *pAppDelegate = new AppDelegate();
CCApplication::sharedApplication()->run();
Application::sharedApplication()->run();
}
else
{
ccDrawInit();
ccGLInvalidateStateCache();
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
CCTextureCache::reloadAllTextures();
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
CCDirector::sharedDirector()->setGLDefaultValues();
ShaderCache::sharedShaderCache()->reloadDefaultShaders();
TextureCache::reloadAllTextures();
NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::sharedDirector()->setGLDefaultValues();
}
}

View File

@ -25,8 +25,8 @@ int main(int argc, char **argv)
height = 600;
}
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
EGLView* eglView = EGLView::sharedOpenGLView();
eglView->setFrameSize(width, height);
return CCApplication::sharedApplication()->run();
return Application::sharedApplication()->run();
}

View File

@ -73,7 +73,7 @@ static AppDelegate s_sharedApplication;
[[UIApplication sharedApplication] setStatusBarHidden: YES];
cocos2d::CCApplication::sharedApplication()->run();
cocos2d::Application::sharedApplication()->run();
return YES;
}
@ -83,14 +83,14 @@ static AppDelegate s_sharedApplication;
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.
*/
cocos2d::CCDirector::sharedDirector()->pause();
cocos2d::Director::sharedDirector()->pause();
}
- (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.
*/
cocos2d::CCDirector::sharedDirector()->resume();
cocos2d::Director::sharedDirector()->resume();
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
@ -98,14 +98,14 @@ static AppDelegate s_sharedApplication;
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.
*/
cocos2d::CCApplication::sharedApplication()->applicationDidEnterBackground();
cocos2d::Application::sharedApplication()->applicationDidEnterBackground();
}
- (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.
*/
cocos2d::CCApplication::sharedApplication()->applicationWillEnterForeground();
cocos2d::Application::sharedApplication()->applicationWillEnterForeground();
}
- (void)applicationWillTerminate:(UIApplication *)application {
@ -123,7 +123,7 @@ static AppDelegate s_sharedApplication;
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
cocos2d::CCDirector::sharedDirector()->purgeCachedData();
cocos2d::Director::sharedDirector()->purgeCachedData();
}

View File

@ -13,7 +13,7 @@ int main(int argc, char **argv)
{
// create the application instance
AppDelegate app;
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
EGLView* eglView = EGLView::sharedOpenGLView();
eglView->setFrameSize(800, 480);
return CCApplication::sharedApplication()->run();
return Application::sharedApplication()->run();
}

View File

@ -15,5 +15,5 @@ int main()
{
AppDelegate app;
return cocos2d::CCApplication::sharedApplication()->Run();
return cocos2d::Application::sharedApplication()->Run();
}

View File

@ -24,11 +24,11 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
// create the application instance
AppDelegate app;
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
EGLView* eglView = EGLView::sharedOpenGLView();
eglView->setViewName("HelloLua");
eglView->setFrameSize(480, 320);
int ret = CCApplication::sharedApplication()->run();
int ret = Application::sharedApplication()->run();
#ifdef USE_WIN32_CONSOLE
FreeConsole();

View File

@ -59,7 +59,7 @@ static AppDelegate s_sharedApplication;
[[UIApplication sharedApplication] setStatusBarHidden: YES];
cocos2d::CCApplication::sharedApplication()->run();
cocos2d::Application::sharedApplication()->run();
return YES;
}
@ -69,14 +69,14 @@ static AppDelegate s_sharedApplication;
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.
*/
cocos2d::CCDirector::sharedDirector()->pause();
cocos2d::Director::sharedDirector()->pause();
}
- (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.
*/
cocos2d::CCDirector::sharedDirector()->resume();
cocos2d::Director::sharedDirector()->resume();
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
@ -84,14 +84,14 @@ static AppDelegate s_sharedApplication;
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.
*/
cocos2d::CCApplication::sharedApplication()->applicationDidEnterBackground();
cocos2d::Application::sharedApplication()->applicationDidEnterBackground();
}
- (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.
*/
cocos2d::CCApplication::sharedApplication()->applicationWillEnterForeground();
cocos2d::Application::sharedApplication()->applicationWillEnterForeground();
}
- (void)applicationWillTerminate:(UIApplication *)application {
@ -109,7 +109,7 @@ static AppDelegate s_sharedApplication;
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
cocos2d::CCDirector::sharedDirector()->purgeCachedData();
cocos2d::Director::sharedDirector()->purgeCachedData();
}

View File

@ -27,8 +27,8 @@ AppDelegate::~AppDelegate()
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
Director *pDirector = Director::sharedDirector();
pDirector->setOpenGLView(EGLView::sharedOpenGLView());
// turn on display FPS
pDirector->setDisplayStats(true);
@ -37,7 +37,7 @@ bool AppDelegate::applicationDidFinishLaunching()
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene();
Scene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
@ -48,7 +48,7 @@ bool AppDelegate::applicationDidFinishLaunching()
// 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()->stopAnimation();
Director::sharedDirector()->stopAnimation();
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
SimpleAudioEngine::sharedEngine()->pauseAllEffects();
}
@ -56,7 +56,7 @@ void AppDelegate::applicationDidEnterBackground()
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->startAnimation();
Director::sharedDirector()->startAnimation();
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
SimpleAudioEngine::sharedEngine()->resumeAllEffects();
}

View File

@ -14,16 +14,16 @@
/**
@brief The cocos2d Application.
The reason to implement with private inheritance is to hide some interface details of CCDirector.
The reason to implement with private inheritance is to hide some interface details of Director.
*/
class AppDelegate : private cocos2d::CCApplication
class AppDelegate : private cocos2d::Application
{
public:
AppDelegate();
virtual ~AppDelegate();
/**
@brief Implement CCDirector and CCScene init code here.
@brief Implement Director and Scene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/

View File

@ -4,10 +4,10 @@
using namespace cocos2d;
using namespace CocosDenshion;
CCScene* HelloWorld::scene()
Scene* HelloWorld::scene()
{
// 'scene' is an autorelease object
CCScene *scene = CCScene::create();
Scene *scene = Scene::create();
// 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::create();
@ -24,7 +24,7 @@ bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
if ( !Layer::init() )
{
return false;
}
@ -34,16 +34,16 @@ bool HelloWorld::init()
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
MenuItemImage *pCloseItem = MenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback) );
pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );
pCloseItem->setPosition( ccp(Director::sharedDirector()->getWinSize().width - 20, 20) );
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition( CCPointZero );
Menu* pMenu = Menu::create(pCloseItem, NULL);
pMenu->setPosition( PointZero );
this->addChild(pMenu, 1);
/////////////////////////////
@ -51,10 +51,10 @@ bool HelloWorld::init()
// add a label shows "Hello World"
// create and initialize a label
CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Thonburi", 34);
LabelTTF* pLabel = LabelTTF::create("Hello World", "Thonburi", 34);
// ask director the window size
CCSize size = CCDirector::sharedDirector()->getWinSize();
Size size = Director::sharedDirector()->getWinSize();
// position the label on the center of the screen
pLabel->setPosition( ccp(size.width / 2, size.height - 20) );
@ -63,7 +63,7 @@ bool HelloWorld::init()
this->addChild(pLabel, 1);
// add "HelloWorld" splash screen"
CCSprite* pSprite = CCSprite::create("HelloWorld.png");
Sprite* pSprite = Sprite::create("HelloWorld.png");
// position the sprite on the center of the screen
pSprite->setPosition( ccp(size.width/2, size.height/2) );
@ -74,9 +74,9 @@ bool HelloWorld::init()
return true;
}
void HelloWorld::menuCloseCallback(CCObject* pSender)
void HelloWorld::menuCloseCallback(Object* pSender)
{
CCDirector::sharedDirector()->end();
Director::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);

View File

@ -3,17 +3,17 @@
#include "cocos2d.h"
class HelloWorld : public cocos2d::CCLayer
class HelloWorld : public cocos2d::Layer
{
public:
// Method 'init' in cocos2d-x returns bool, instead of 'id' in cocos2d-iphone (an object pointer)
virtual bool init();
// there's no 'id' in cpp, so we recommend to return the class instance pointer
static cocos2d::CCScene* scene();
static cocos2d::Scene* scene();
// a selector callback
void menuCloseCallback(CCObject* pSender);
void menuCloseCallback(Object* pSender);
// preprocessor macro for "static create()" constructor ( node() deprecated )
CREATE_FUNC(HelloWorld);

View File

@ -27,8 +27,8 @@ AppDelegate::~AppDelegate()
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
Director *pDirector = Director::sharedDirector();
pDirector->setOpenGLView(EGLView::sharedOpenGLView());
// turn on display FPS
pDirector->setDisplayStats(true);
@ -37,7 +37,7 @@ bool AppDelegate::applicationDidFinishLaunching()
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene();
Scene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
@ -48,7 +48,7 @@ bool AppDelegate::applicationDidFinishLaunching()
// 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()->stopAnimation();
Director::sharedDirector()->stopAnimation();
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
SimpleAudioEngine::sharedEngine()->pauseAllEffects();
}
@ -56,7 +56,7 @@ void AppDelegate::applicationDidEnterBackground()
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->startAnimation();
Director::sharedDirector()->startAnimation();
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
SimpleAudioEngine::sharedEngine()->resumeAllEffects();
}

View File

@ -14,9 +14,9 @@
/**
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by CCDirector.
The reason for implement as private inheritance is to hide some interface call by Director.
*/
class AppDelegate : private cocos2d::CCApplication
class AppDelegate : private cocos2d::Application
{
public:
AppDelegate();
@ -24,7 +24,7 @@ public:
/**
@brief Implement CCDirector and CCScene init code here.
@brief Implement Director and Scene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/

View File

@ -37,7 +37,7 @@ bool PhysicsSprite::isDirty(void)
}
// returns the transform matrix according the Chipmunk Body values
CCAffineTransform PhysicsSprite::nodeToParentTransform(void)
AffineTransform PhysicsSprite::nodeToParentTransform(void)
{
b2Vec2 pos = _body->GetPosition();
@ -54,13 +54,13 @@ CCAffineTransform PhysicsSprite::nodeToParentTransform(void)
float c = cosf(radians);
float s = sinf(radians);
if( ! _anchorPointInPoints.equals(CCPointZero) ){
if( ! _anchorPointInPoints.equals(PointZero) ){
x += c*-_anchorPointInPoints.x + -s*-_anchorPointInPoints.y;
y += s*-_anchorPointInPoints.x + c*-_anchorPointInPoints.y;
}
// Rot, Translate Matrix
_transform = CCAffineTransformMake( c, s,
_transform = AffineTransformMake( c, s,
-s, c,
x, y );
@ -72,11 +72,11 @@ HelloWorld::HelloWorld()
setTouchEnabled( true );
setAccelerometerEnabled( true );
CCSize s = CCDirector::sharedDirector()->getWinSize();
Size s = Director::sharedDirector()->getWinSize();
// init physics
this->initPhysics();
CCSpriteBatchNode *parent = CCSpriteBatchNode::create("blocks.png", 100);
SpriteBatchNode *parent = SpriteBatchNode::create("blocks.png", 100);
_spriteTexture = parent->getTexture();
addChild(parent, 0, kTagParentNode);
@ -84,7 +84,7 @@ HelloWorld::HelloWorld()
addNewSpriteAtPosition(ccp(s.width/2, s.height/2));
CCLabelTTF *label = CCLabelTTF::create("Tap screen", "Marker Felt", 32);
LabelTTF *label = LabelTTF::create("Tap screen", "Marker Felt", 32);
addChild(label, 0);
label->setColor(ccc3(0,0,255));
label->setPosition(ccp( s.width/2, s.height-50));
@ -103,7 +103,7 @@ HelloWorld::~HelloWorld()
void HelloWorld::initPhysics()
{
CCSize s = CCDirector::sharedDirector()->getWinSize();
Size s = Director::sharedDirector()->getWinSize();
b2Vec2 gravity;
gravity.Set(0.0f, -10.0f);
@ -163,9 +163,9 @@ void HelloWorld::draw()
// This is only for debug purposes
// It is recommend to disable it
//
CCLayer::draw();
Layer::draw();
ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
kmGLPushMatrix();
@ -174,10 +174,10 @@ void HelloWorld::draw()
kmGLPopMatrix();
}
void HelloWorld::addNewSpriteAtPosition(CCPoint p)
void HelloWorld::addNewSpriteAtPosition(Point p)
{
CCLOG("Add sprite %0.2f x %02.f",p.x,p.y);
CCNode* parent = getChildByTag(kTagParentNode);
Node* parent = getChildByTag(kTagParentNode);
//We have a 64x64 sprite sheet with 4 different 32x32 images. The following code is
//just randomly picking one of the images
@ -233,41 +233,41 @@ void HelloWorld::update(float dt)
{
if (b->GetUserData() != NULL) {
//Synchronize the AtlasSprites position and rotation with the corresponding body
CCSprite* myActor = (CCSprite*)b->GetUserData();
Sprite* myActor = (Sprite*)b->GetUserData();
myActor->setPosition( CCPointMake( b->GetPosition().x * PTM_RATIO, b->GetPosition().y * PTM_RATIO) );
myActor->setRotation( -1 * CC_RADIANS_TO_DEGREES(b->GetAngle()) );
}
}
}
void HelloWorld::ccTouchesEnded(CCSet* touches, CCEvent* event)
void HelloWorld::ccTouchesEnded(Set* touches, Event* event)
{
//Add a new body/atlas sprite at the touched location
CCSetIterator it;
CCTouch* touch;
SetIterator it;
Touch* touch;
for( it = touches->begin(); it != touches->end(); it++)
{
touch = (CCTouch*)(*it);
touch = (Touch*)(*it);
if(!touch)
break;
CCPoint location = touch->getLocationInView();
Point location = touch->getLocationInView();
location = CCDirector::sharedDirector()->convertToGL(location);
location = Director::sharedDirector()->convertToGL(location);
addNewSpriteAtPosition( location );
}
}
CCScene* HelloWorld::scene()
Scene* HelloWorld::scene()
{
// 'scene' is an autorelease object
CCScene *scene = CCScene::create();
Scene *scene = Scene::create();
// add layer as a child to scene
CCLayer* layer = new HelloWorld();
Layer* layer = new HelloWorld();
scene->addChild(layer);
layer->release();

View File

@ -12,36 +12,36 @@
#include "cocos2d.h"
#include "Box2D.h"
class PhysicsSprite : public cocos2d::CCSprite
class PhysicsSprite : public cocos2d::Sprite
{
public:
PhysicsSprite();
void setPhysicsBody(b2Body * body);
virtual bool isDirty(void);
virtual cocos2d::CCAffineTransform nodeToParentTransform(void);
virtual cocos2d::AffineTransform nodeToParentTransform(void);
private:
b2Body* _body; // strong ref
};
class HelloWorld : public cocos2d::CCLayer {
class HelloWorld : public cocos2d::Layer {
public:
~HelloWorld();
HelloWorld();
// returns a Scene that contains the HelloWorld as the only child
static cocos2d::CCScene* scene();
static cocos2d::Scene* scene();
void initPhysics();
// adds a new sprite at a given coordinate
void addNewSpriteAtPosition(cocos2d::CCPoint p);
void addNewSpriteAtPosition(cocos2d::Point p);
virtual void draw();
virtual void ccTouchesEnded(cocos2d::CCSet* touches, cocos2d::CCEvent* event);
virtual void ccTouchesEnded(cocos2d::Set* touches, cocos2d::Event* event);
void update(float dt);
private:
b2World* world;
cocos2d::CCTexture2D* _spriteTexture; // weak ref
cocos2d::Texture2D* _spriteTexture; // weak ref
};
#endif // __HELLO_WORLD_H__

View File

@ -27,8 +27,8 @@ AppDelegate::~AppDelegate()
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
Director *pDirector = Director::sharedDirector();
pDirector->setOpenGLView(EGLView::sharedOpenGLView());
// turn on display FPS
pDirector->setDisplayStats(true);
@ -37,7 +37,7 @@ bool AppDelegate::applicationDidFinishLaunching()
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene();
Scene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
@ -48,7 +48,7 @@ bool AppDelegate::applicationDidFinishLaunching()
// 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()->stopAnimation();
Director::sharedDirector()->stopAnimation();
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
SimpleAudioEngine::sharedEngine()->pauseAllEffects();
}
@ -56,7 +56,7 @@ void AppDelegate::applicationDidEnterBackground()
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->startAnimation();
Director::sharedDirector()->startAnimation();
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
SimpleAudioEngine::sharedEngine()->resumeAllEffects();
}

View File

@ -14,16 +14,16 @@
/**
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by CCDirector.
The reason for implement as private inheritance is to hide some interface call by Director.
*/
class AppDelegate : private cocos2d::CCApplication
class AppDelegate : private cocos2d::Application
{
public:
AppDelegate();
virtual ~AppDelegate();
/**
@brief Implement CCDirector and CCScene init code here.
@brief Implement Director and Scene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/

View File

@ -48,7 +48,7 @@ bool ChipmunkPhysicsSprite::isDirty(void)
return true;
}
CCAffineTransform ChipmunkPhysicsSprite::nodeToParentTransform(void)
AffineTransform ChipmunkPhysicsSprite::nodeToParentTransform(void)
{
float x = _body->p.x;
float y = _body->p.y;
@ -62,13 +62,13 @@ CCAffineTransform ChipmunkPhysicsSprite::nodeToParentTransform(void)
float c = _body->rot.x;
float s = _body->rot.y;
if( ! _anchorPointInPoints.equals(CCPointZero) ){
if( ! _anchorPointInPoints.equals(PointZero) ){
x += c*-_anchorPointInPoints.x + -s*-_anchorPointInPoints.y;
y += s*-_anchorPointInPoints.x + c*-_anchorPointInPoints.y;
}
// Rot, Translate Matrix
_transform = CCAffineTransformMake( c, s,
_transform = AffineTransformMake( c, s,
-s, c,
x, y );
@ -90,10 +90,10 @@ HelloWorld::~HelloWorld()
}
CCScene* HelloWorld::scene()
Scene* HelloWorld::scene()
{
// 'scene' is an autorelease object.
CCScene *scene = CCScene::create();
Scene *scene = Scene::create();
// 'layer' is an autorelease object.
HelloWorld *layer = HelloWorld::create();
@ -107,7 +107,7 @@ CCScene* HelloWorld::scene()
bool HelloWorld::init()
{
if (!CCLayer::init())
if (!Layer::init())
{
return false;
}
@ -116,10 +116,10 @@ bool HelloWorld::init()
setTouchEnabled(true);
setAccelerometerEnabled(true);
CCSize s = CCDirector::sharedDirector()->getWinSize();
Size s = Director::sharedDirector()->getWinSize();
// title
CCLabelTTF *label = CCLabelTTF::create("Multi touch the screen", "Marker Felt", 36);
LabelTTF *label = LabelTTF::create("Multi touch the screen", "Marker Felt", 36);
label->setPosition(ccp( s.width / 2, s.height - 30));
this->addChild(label, -1);
@ -128,12 +128,12 @@ bool HelloWorld::init()
#if 1
// Use batch node. Faster
CCSpriteBatchNode *parent = CCSpriteBatchNode::create("grossini_dance_atlas.png", 100);
SpriteBatchNode *parent = SpriteBatchNode::create("grossini_dance_atlas.png", 100);
_spriteTexture = parent->getTexture();
#else
// doesn't use batch node. Slower
_spriteTexture = CCTextureCache::sharedTextureCache()->addImage("grossini_dance_atlas.png");
CCNode *parent = CCNode::node();
_spriteTexture = TextureCache::sharedTextureCache()->addImage("grossini_dance_atlas.png");
Node *parent = Node::node();
#endif
addChild(parent, 0, kTagParentNode);
@ -147,7 +147,7 @@ bool HelloWorld::init()
void HelloWorld::initPhysics()
{
CCSize s = CCDirector::sharedDirector()->getWinSize();
Size s = Director::sharedDirector()->getWinSize();
// init chipmunk
cpInitChipmunk();
@ -183,18 +183,18 @@ void HelloWorld::update(float delta)
{
// Should use a fixed size step based on the animation interval.
int steps = 2;
float dt = CCDirector::sharedDirector()->getAnimationInterval()/(float)steps;
float dt = Director::sharedDirector()->getAnimationInterval()/(float)steps;
for(int i=0; i<steps; i++){
cpSpaceStep(_space, dt);
}
}
void HelloWorld::addNewSpriteAtPosition(CCPoint pos)
void HelloWorld::addNewSpriteAtPosition(Point pos)
{
int posx, posy;
CCNode *parent = getChildByTag(kTagParentNode);
Node *parent = getChildByTag(kTagParentNode);
posx = CCRANDOM_0_1() * 200.0f;
posy = CCRANDOM_0_1() * 200.0f;
@ -230,28 +230,28 @@ void HelloWorld::addNewSpriteAtPosition(CCPoint pos)
sprite->setPhysicsBody(body);
}
void HelloWorld::ccTouchesEnded(CCSet* touches, CCEvent* event)
void HelloWorld::ccTouchesEnded(Set* touches, Event* event)
{
//Add a new body/atlas sprite at the touched location
CCSetIterator it;
CCTouch* touch;
SetIterator it;
Touch* touch;
for( it = touches->begin(); it != touches->end(); it++)
{
touch = (CCTouch*)(*it);
touch = (Touch*)(*it);
if(!touch)
break;
CCPoint location = touch->getLocationInView();
Point location = touch->getLocationInView();
location = CCDirector::sharedDirector()->convertToGL(location);
location = Director::sharedDirector()->convertToGL(location);
addNewSpriteAtPosition( location );
}
}
void HelloWorld::didAccelerate(CCAcceleration* pAccelerationValue)
void HelloWorld::didAccelerate(Acceleration* pAccelerationValue)
{
static float prevX=0, prevY=0;
@ -263,7 +263,7 @@ void HelloWorld::didAccelerate(CCAcceleration* pAccelerationValue)
prevX = accelX;
prevY = accelY;
CCPoint v = ccp( accelX, accelY);
Point v = ccp( accelX, accelY);
v = ccpMult(v, 200);
_space->gravity = cpv(v.x, v.y);
}

View File

@ -14,35 +14,35 @@
// include Chipmunk headers
#include "chipmunk.h"
class ChipmunkPhysicsSprite : public cocos2d::CCSprite
class ChipmunkPhysicsSprite : public cocos2d::Sprite
{
public:
ChipmunkPhysicsSprite();
virtual ~ChipmunkPhysicsSprite();
void setPhysicsBody(cpBody* body);
virtual bool isDirty(void);
virtual cocos2d::CCAffineTransform nodeToParentTransform(void);
virtual cocos2d::AffineTransform nodeToParentTransform(void);
private:
cpBody* _body; // strong ref
};
// HelloWorld Layer
class HelloWorld : public cocos2d::CCLayer {
class HelloWorld : public cocos2d::Layer {
public:
HelloWorld();
~HelloWorld();
bool init();
static cocos2d::CCScene* scene();
static cocos2d::Scene* scene();
CREATE_FUNC(HelloWorld);
void initPhysics();
void addNewSpriteAtPosition(cocos2d::CCPoint p);
void addNewSpriteAtPosition(cocos2d::Point p);
void update(float dt);
virtual void ccTouchesEnded(cocos2d::CCSet* touches, cocos2d::CCEvent* event);
virtual void didAccelerate(cocos2d::CCAcceleration* pAccelerationValue);
virtual void ccTouchesEnded(cocos2d::Set* touches, cocos2d::Event* event);
virtual void didAccelerate(cocos2d::Acceleration* pAccelerationValue);
private:
cocos2d::CCTexture2D* _spriteTexture; // weak ref
cocos2d::Texture2D* _spriteTexture; // weak ref
cpSpace* _space; // strong ref
cpShape* _walls[4];

View File

@ -28,8 +28,8 @@ AppDelegate::~AppDelegate()
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
Director *pDirector = Director::sharedDirector();
pDirector->setOpenGLView(EGLView::sharedOpenGLView());
// turn on display FPS
pDirector->setDisplayStats(true);
@ -50,8 +50,8 @@ bool AppDelegate::applicationDidFinishLaunching()
sc->start();
CCScriptEngineProtocol *pEngine = ScriptingCore::getInstance();
CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
ScriptEngineProtocol *pEngine = ScriptingCore::getInstance();
ScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
ScriptingCore::getInstance()->runScript("hello.js");
return true;
@ -61,11 +61,11 @@ void handle_signal(int signal) {
static int internal_state = 0;
ScriptingCore* sc = ScriptingCore::getInstance();
// should start everything back
CCDirector* director = CCDirector::sharedDirector();
Director* director = Director::sharedDirector();
if (director->getRunningScene()) {
director->popToRootScene();
} else {
CCPoolManager::sharedPoolManager()->finalize();
PoolManager::sharedPoolManager()->finalize();
if (internal_state == 0) {
//sc->dumpRoot(NULL, 0, NULL);
sc->start();
@ -80,7 +80,7 @@ void handle_signal(int signal) {
// 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()->stopAnimation();
Director::sharedDirector()->stopAnimation();
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
SimpleAudioEngine::sharedEngine()->pauseAllEffects();
}
@ -88,7 +88,7 @@ void AppDelegate::applicationDidEnterBackground()
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->startAnimation();
Director::sharedDirector()->startAnimation();
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
SimpleAudioEngine::sharedEngine()->resumeAllEffects();
}

View File

@ -13,16 +13,16 @@
/**
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by CCDirector.
The reason for implement as private inheritance is to hide some interface call by Director.
*/
class AppDelegate : private cocos2d::CCApplication
class AppDelegate : private cocos2d::Application
{
public:
AppDelegate();
virtual ~AppDelegate();
/**
@brief Implement CCDirector and CCScene init code here.
@brief Implement Director and Scene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/

View File

@ -23,8 +23,8 @@ AppDelegate::~AppDelegate()
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
Director *pDirector = Director::sharedDirector();
pDirector->setOpenGLView(EGLView::sharedOpenGLView());
// turn on display FPS
pDirector->setDisplayStats(true);
@ -33,10 +33,10 @@ bool AppDelegate::applicationDidFinishLaunching()
pDirector->setAnimationInterval(1.0 / 60);
// register lua engine
CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
LuaEngine* pEngine = LuaEngine::defaultEngine();
ScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
std::string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("hello.lua");
std::string path = FileUtils::sharedFileUtils()->fullPathForFilename("hello.lua");
pEngine->executeScriptFile(path.c_str());
return true;
@ -45,7 +45,7 @@ bool AppDelegate::applicationDidFinishLaunching()
// 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()->stopAnimation();
Director::sharedDirector()->stopAnimation();
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
SimpleAudioEngine::sharedEngine()->pauseAllEffects();
}
@ -53,7 +53,7 @@ void AppDelegate::applicationDidEnterBackground()
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->startAnimation();
Director::sharedDirector()->startAnimation();
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
SimpleAudioEngine::sharedEngine()->resumeAllEffects();
}

View File

@ -6,16 +6,16 @@
/**
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by CCDirector.
The reason for implement as private inheritance is to hide some interface call by Director.
*/
class AppDelegate : private cocos2d::CCApplication
class AppDelegate : private cocos2d::Application
{
public:
AppDelegate();
virtual ~AppDelegate();
/**
@brief Implement CCDirector and CCScene init code here.
@brief Implement Director and Scene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/