2012-04-19 14:35:52 +08:00
|
|
|
#include "AppDelegate.h"
|
|
|
|
|
|
|
|
#include "cocos2d.h"
|
2012-07-19 17:22:36 +08:00
|
|
|
#include "controller.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
#include "SimpleAudioEngine.h"
|
2013-06-06 12:02:54 +08:00
|
|
|
#include "cocos-ext.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
USING_NS_CC;
|
|
|
|
using namespace CocosDenshion;
|
|
|
|
|
|
|
|
AppDelegate::AppDelegate()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
AppDelegate::~AppDelegate()
|
|
|
|
{
|
|
|
|
// SimpleAudioEngine::end();
|
2013-06-06 12:02:54 +08:00
|
|
|
cocos2d::extension::CCArmatureDataManager::sharedArmatureDataManager()->purgeArmatureSystem();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AppDelegate::applicationDidFinishLaunching()
|
|
|
|
{
|
2013-06-07 03:23:44 +08:00
|
|
|
// As an example, load config file
|
|
|
|
// XXX: This should be loaded before the Director is initialized,
|
|
|
|
// XXX: but at this point, the director is already initialized
|
|
|
|
CCConfiguration::sharedConfiguration()->loadConfigFile("configs/config-example.plist");
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// initialize director
|
|
|
|
CCDirector *pDirector = CCDirector::sharedDirector();
|
2012-08-21 14:58:31 +08:00
|
|
|
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-10-12 17:37:26 +08:00
|
|
|
CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
|
2012-08-23 14:20:32 +08:00
|
|
|
|
2013-05-06 22:18:07 +08:00
|
|
|
#ifdef TIZEN
|
|
|
|
CCSize designSize = CCSizeMake(1280, 720);
|
|
|
|
#else
|
2012-10-23 17:48:50 +08:00
|
|
|
CCSize designSize = CCSizeMake(480, 320);
|
2013-05-06 22:18:07 +08:00
|
|
|
#endif
|
2013-01-28 17:44:53 +08:00
|
|
|
CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils();
|
2012-10-23 17:48:50 +08:00
|
|
|
|
|
|
|
if (screenSize.height > 320)
|
2012-10-12 17:37:26 +08:00
|
|
|
{
|
2012-10-23 17:48:50 +08:00
|
|
|
CCSize resourceSize = CCSizeMake(960, 640);
|
2013-01-28 17:44:53 +08:00
|
|
|
std::vector<std::string> searchPaths;
|
|
|
|
searchPaths.push_back("hd");
|
2013-01-29 09:56:38 +08:00
|
|
|
pFileUtils->setSearchPaths(searchPaths);
|
2012-10-23 17:48:50 +08:00
|
|
|
pDirector->setContentScaleFactor(resourceSize.height/designSize.height);
|
2012-10-12 17:37:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCScene * pScene = CCScene::create();
|
2012-04-19 14:35:52 +08:00
|
|
|
CCLayer * pLayer = new TestController();
|
|
|
|
pLayer->autorelease();
|
|
|
|
|
|
|
|
pScene->addChild(pLayer);
|
|
|
|
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()
|
|
|
|
{
|
2012-06-21 11:42:49 +08:00
|
|
|
CCDirector::sharedDirector()->stopAnimation();
|
2012-04-19 14:35:52 +08:00
|
|
|
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
|
|
|
|
SimpleAudioEngine::sharedEngine()->pauseAllEffects();
|
|
|
|
}
|
|
|
|
|
|
|
|
// this function will be called when the app is active again
|
|
|
|
void AppDelegate::applicationWillEnterForeground()
|
|
|
|
{
|
2012-06-21 11:42:49 +08:00
|
|
|
CCDirector::sharedDirector()->startAnimation();
|
2012-04-19 14:35:52 +08:00
|
|
|
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
|
|
|
|
SimpleAudioEngine::sharedEngine()->resumeAllEffects();
|
|
|
|
}
|