123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- #include "AppDelegate.h"
- #include "TestScene.h"
- USING_NS_CC;
- #include "common/BigFile.h"
- #include "reboltBt_behaviac_agent_meta.h"
- #include "BTManger.hpp"
- //#include "ProjectLauncher.h"
- static cocos2d::Size designResolutionSize = cocos2d::Size(640, 1136);
- static cocos2d::Size smallResolutionSize = cocos2d::Size(640, 1136);
- static cocos2d::Size mediumResolutionSize = cocos2d::Size(640, 1136);
- static cocos2d::Size largeResolutionSize = cocos2d::Size(640, 1136);
- AppDelegate::AppDelegate()
- {
- }
- AppDelegate::~AppDelegate()
- {
- }
- // if you want a different context, modify the value of glContextAttrs
- // it will affect all platforms
- void AppDelegate::initGLContextAttrs()
- {
- // set OpenGL context attributes: red,green,blue,alpha,depth,stencil
- GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
- GLView::setGLContextAttrs(glContextAttrs);
- }
- // if you want to use the package manager to install more packages,
- // don't modify or remove this function
- static int register_all_packages()
- {
- return 0; //flag for packages manager
- }
- void AppDelegate::_initBehaviac() {
- behaviac::reboltBtLoader::addMetaToRedLader();
- behaviac::Workspace::GetInstance()->SetFilePath("");
- behaviac::Workspace::GetInstance()->SetFileFormat(behaviac::Workspace::EFF_xml);
- BTManger::getInstance()->setRootPath("");
- BTManger::getInstance()->startGame();
- }
- bool AppDelegate::applicationDidFinishLaunching() {
- // initialize director
- BigFile::getInstance();
-
- FileUtils* fileUtils = FileUtils::getInstance();
- // string writePath = fileUtils->getWritablePath();
- //#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC
- // writePath = writePath + BulldogPlatform::getInstance()->getPackageName()+"/";
- // if(!fileUtils->isDirectoryExist(writePath)){
- // fileUtils->createDirectory(writePath);
- // }
- // fileUtils->setWritablePath(writePath);
- //#else
- //
- //#endif
-
- Director* director = Director::getInstance();
-
- director->getScheduler()->setTimeScale(1.f);
-
- auto glview = director->getOpenGLView();
- if(!glview) {
- #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
- Rect _rect;
- float _scale;
-
- _rect = Rect(0, 0, 720, 1280);
- _scale=0.8f;
- glview = GLViewImpl::createWithRect("ccProj", cocos2d::Rect(0, 0, designResolutionSize.width/2, designResolutionSize.height/2) ,1.5);
- #else
- glview = GLViewImpl::create("ccProj");
- #endif
- director->setOpenGLView(glview);
- }
-
- fileUtils->addSearchPath("res");
- fileUtils->addSearchPath("../Resources");
-
- // turn on display FPS
- director->setDisplayStats(true);
- // set FPS. the default value is 1.0/60 if you don't call this
- director->setAnimationInterval(1.0f/60);
- Size designSz(640,1136);//640X1136
- Size winSz = director->getWinSize();
- float factor1 = designSz.width*1.0/designSz.height;//0.667
- float factor2 = winSz.width/winSz.height;//0.561
-
- Size setSize(designSz.width,designSz.height);
- if(factor2<factor1)
- {
- glview->setDesignResolutionSize(designSz.width,designSz.width/factor2,ResolutionPolicy::FIXED_WIDTH);
- }
- else
- {
- glview->setDesignResolutionSize(factor2*designSz.height,designSz.height,ResolutionPolicy::FIXED_HEIGHT);
- }
- register_all_packages();
- _initBehaviac();
-
- auto scene = TestScene::createScene();
-
- director->pushScene(scene);
-
- // demo_StartGame();
-
- return true;
- }
- // This function will be called when the app is inactive. Note, when receiving a phone call it is invoked.
- void AppDelegate::applicationDidEnterBackground() {
- Director::getInstance()->stopAnimation();
- // demo_applicationDidEnterBackground();
-
- }
- // this function will be called when the app is active again
- void AppDelegate::applicationWillEnterForeground() {
-
- Director::getInstance()->startAnimation();
-
- // demo_applicationWillEnterForeground();
-
- }
|