bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. // pDirector->enableRetinaDisplay(true); // sets landscape mode // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); // turn on display FPS pDirector->setDisplayFPS(true); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); // create a scene. it's an autorelease object CCScene *pScene = HelloWorld::scene(); // run pDirector->runWithScene(pScene); return true; }
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 opengl landscape mode // tests set device orientation in RootViewController.mm // 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); CCScene * pScene = CCScene::node(); CCLayer * pLayer = new TestController(); pLayer->autorelease(); pScene->addChild(pLayer); //pDirector->runWithScene(HelloWorld::scene()); pDirector->runWithScene(pScene); return true; }
bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); // turn on display FPS pDirector->setDisplayFPS(false); //pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); // create a scene. it's an autorelease object CCScene *pScene = HelloWorld::scene(); // run pDirector->runWithScene(pScene); return true; }
bool AppDelegate::applicationDidFinishLaunching() { // init the window if (!(m_pMainWnd = new CCXEGLView(this)) || ! m_pMainWnd->Create(&TRectangle(0,0,GetScreenWidth(),GetScreenHeight()))) { CCX_SAFE_DELETE(m_pMainWnd); return false; } // init director CCDirector * pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(m_pMainWnd); pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); // pDirector->setDeviceOrientation(kCCDeviceOrientationPortrait); pDirector->setDisplayFPS(true); // set the resource path CCFileUtils::setResourcePath("/NEWPLUS/TDA_DATA/Data/[!output PROJECT_NAME]/"); [! if CCX_USE_UI_RESOURCE] // cocos2d find image in ResourceEntry first, in ResourcePath second. // set the ResourceEntry, CCFileUtils::setResourceEntry(&[!output PROJECT_NAME]ResourceEntry); // set the Images ResInfo (name and ResID) CCFileUtils::setResourceInfo(ResInfo, sizeof(ResInfo) / sizeof(T_ResourceInfo)); [! endif] CCScene * pScene = HelloWorld::scene(); pDirector->runWithScene(pScene); 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); // run // this is crashing for me every time if I just pass a plain cstr #ifdef TESTBUILD // TestScene *ts = new TestScene(); // ts->init(); // CCDirector::sharedDirector()->runWithScene(ts); ScriptingCore::getInstance().runScript("JS/main-testbuild.js"); #else ScriptingCore::getInstance().runScript("JS/main.js"); // TestScene *ts = new TestScene(); // ts->init(); // CCDirector::sharedDirector()->runWithScene(ts); #endif 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); // turn on display FPS pDirector->setDisplayFPS(true); // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); // register lua engine CCScriptEngineProtocol* pEngine = CCLuaEngine::engine(); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) unsigned long size; #ifdef KILLA char *pFileContent = (char*)CCFileUtils::getFileData("boot.kia", "r", &size); #else char *pFileContent = (char*)CCFileUtils::getFileData("boot.lua", "r", &size); #endif if (pFileContent) { // copy the file contents and add '\0' at the end, or the lua parser can not parse it char *pCodes = new char[size + 1]; pCodes[size] = '\0'; memcpy(pCodes, pFileContent, size); delete[] pFileContent; pEngine->executeString(pCodes); delete []pCodes; } #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE) #ifdef KILLA string path = CCFileUtils::fullPathFromRelativePath("boot.kia"); #else string path = CCFileUtils::fullPathFromRelativePath("boot.lua"); #endif pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); pEngine->executeScriptFile(path.c_str()); #endif return true; }
//初始化引擎 void Ag2dEngine::start() { CCDirector* director = CCDirector::sharedDirector(); //初始化场景导演 director->setOpenGLView(&CCEGLView::sharedOpenGLView()); director->enableRetinaDisplay(CONF_ENABLE_RETINA); director->setDisplayFPS(CONF_SHOW_FPS); director->setAnimationInterval(CONF_FPS_VAL); //启动 playScene( reg_scene ); }
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); // 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); [! if CC_USE_LUA] // init lua engine CCLuaEngine* pEngine = CCLuaEngine::sharedEngine(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) unsigned long size; char *pFileContent = (char*)CCFileUtils::getFileData("hello.lua", "r", &size); if (pFileContent) { // copy the file contents and add '\0' at the end, or the lua parser can not parse it char *pCodes = new char[size + 1]; pCodes[size] = '\0'; memcpy(pCodes, pFileContent, size); delete[] pFileContent; pEngine->executeString(pCodes); delete []pCodes; } #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) string path = CCFileUtils::fullPathFromRelativePath("hello.lua"); pEngine->executeScriptFile(path.c_str()); #endif [! else] // create a scene. it's an autorelease object CCScene *pScene = HelloWorld::scene(); // run pDirector->runWithScene(pScene); [! endif] return true; }
bool AppDelegate::applicationDidFinishLaunching() { CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); pDirector->setDisplayFPS(true); pDirector->setAnimationInterval(1.0 / 60); //初始化动画管理器 sAnimationMgr->initAnimationMap(); //创建游戏主界面 CCScene *pScene = GameScene::playNewGame(); //让director运行场景 pDirector->runWithScene(pScene); return true; }
bool AppDelegate::applicationDidFinishLaunching() { CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); pDirector->enableRetinaDisplay(false); pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); pDirector->setDisplayFPS(false); pDirector->setAnimationInterval(1.0 / 60); pDirector->setDepthTest(false); CCScene *pScene = GameScene::node(); CCDirector::sharedDirector()->runWithScene(pScene); return true; }
void GSceneSelector::RunApplication() { GnSrand( time( 0 ) ); // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); pDirector->setDisplayFPS(true); pDirector->setAnimationInterval(1.0 / 60); CreatePlayingData(); GScene* gameScene = CreateStartScene(); if( gameScene ) pDirector->runWithScene( gameScene ); SetCurrentScene( gameScene ); CCDirector::sharedDirector()->setDisplayFPS(false); }
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() ) ) #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; }
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"cocos2d-win32", 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 { CCX_SAFE_DELETE(m_pMainWnd); return false; } // init director CCDirector * pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(m_pMainWnd); pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); // pDirector->setDeviceOrientation(kCCDeviceOrientationPortrait); pDirector->setDisplayFPS(true); #if defined(CCX_PLATFORM_UPHONE) #if 1 // set the resource path CCFileUtils::setResourcePath("/NEWPLUS/TDA_DATA/Data/cocos2d_tests/"); #else // set the resource zip file CCFileUtils::setResourceZipFile("/NEWPLUS/TDA_DATA/Data/cocos2d_tests/cocos2d_tests.zip"); #endif #elif defined(CCX_PLATFORM_ANDROID) CCFileUtils::setResourcePath("/data/app/org.cocos2dx.tests-1.apk"); CCFileUtils::setRelativePath("assets"); #endif #if 0 // SHOW SPLASH SCREEN // load background image texture and get window size CCTexture2D * pSplashTexture = CCTextureCache::sharedTextureCache()->addImage("b1.png"); CGSize size = CCDirector::sharedDirector()->getWinSize(); // splash sprite CCSprite * pSplashSprite = CCSprite::spriteWithTexture(pSplashTexture); pSplashSprite->setPosition(CGPoint(size.width / 2, size.height / 2)); // splash layer CCLayer * pSplashLayer = new CCLayer(); pSplashLayer->addChild(pSplashSprite); pSplashLayer->autorelease(); // add layer to scene CCScene * pSplashScene = CCScene::node(); pSplashScene->addChild(pSplashLayer); // add scene to director CCDirector::sharedDirector()->runWithScene(pSplashScene); // CCSequence::actions(this, callfunc_selector(AppDelegate::replaceSplashScreen)) m_nTimer = TIMER_Create(3000, TIMER_MODE_NORMAL, TimerCallback1, 0, 0); TIMER_Start(m_nTimer, 0); #endif CCScene * pScene = CCScene::node(); CCLayer * pLayer = new TestController(); pLayer->autorelease(); pScene->addChild(pLayer); pDirector->runWithScene(pScene); 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); // turn on display FPS pDirector->setDisplayFPS(true); // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); // register lua engine m_pLuaEngine = new LuaEngine; CCScriptEngineManager::sharedScriptEngineManager()->setScriptEngine(m_pLuaEngine); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) unsigned long size; char *pFileContent = (char*)CCFileUtils::getFileData("hello.lua", "r", &size); if (pFileContent) { // copy the file contents and add '\0' at the end, or the lua parser can not parse it char *pCodes = new char[size + 1]; pCodes[size] = '\0'; memcpy(pCodes, pFileContent, size); delete[] pFileContent; CCScriptEngineManager::sharedScriptEngineManager()->getScriptEngine()->executeString(pCodes); delete []pCodes; } #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) // CCLuaScriptModule::sharedLuaScriptModule()->executeScriptFile("./../../HelloLua/Resource/hello.lua"); CCScriptEngineManager::sharedScriptEngineManager()->getScriptEngine()->executeScriptFile("./../../HelloLua/Resource/hello.lua"); /* * Another way to run lua script. * Load the file into memory and run it. * unsigned long size; char *pFileContent = (char*)CCFileUtils::getFileData("./../../HelloLua/Resource/hello.lua", "r", &size); if (pFileContent) { // copy the file contents and add '\0' at the end, or the lua parser can not parse it char *pTmp = new char[size + 1]; pTmp[size] = '\0'; memcpy(pTmp, pFileContent, size); delete[] pFileContent; string code(pTmp); CCScriptEngineManager::sharedScriptEngineManager()->getScriptEngine()->excuteScriptFile(code); delete []pTmp; } */ #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) string path = CCFileUtils::fullPathFromRelativePath("hello.lua"); printf("%s", path.c_str()); CCScriptEngineManager::sharedScriptEngineManager()->getScriptEngine()->executeScriptFile(path.c_str()); #endif return true; }