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"
|
2013-06-17 15:54:12 +08:00
|
|
|
#include "CCArmature/utils/CCArmatureDataManager.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
USING_NS_CC;
|
|
|
|
using namespace CocosDenshion;
|
|
|
|
|
|
|
|
AppDelegate::AppDelegate()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
AppDelegate::~AppDelegate()
|
|
|
|
{
|
|
|
|
// SimpleAudioEngine::end();
|
2013-06-20 14:17:10 +08:00
|
|
|
cocos2d::extension::armature::ArmatureDataManager::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
|
2013-07-12 06:24:23 +08:00
|
|
|
Configuration::getInstance()->loadConfigFile("configs/config-example.plist");
|
2013-06-07 03:23:44 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// initialize director
|
2013-07-12 06:24:23 +08:00
|
|
|
Director *pDirector = Director::getInstance();
|
2013-07-12 13:11:21 +08:00
|
|
|
pDirector->setOpenGLView(EGLView::getInstance());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-12 13:11:21 +08:00
|
|
|
Size screenSize = EGLView::getInstance()->getFrameSize();
|
2012-08-23 14:20:32 +08:00
|
|
|
|
2013-07-12 14:30:26 +08:00
|
|
|
Size designSize = Size(480, 320);
|
2013-06-09 18:54:35 +08:00
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
FileUtils* pFileUtils = FileUtils::getInstance();
|
2012-10-23 17:48:50 +08:00
|
|
|
|
|
|
|
if (screenSize.height > 320)
|
2012-10-12 17:37:26 +08:00
|
|
|
{
|
2013-07-12 14:30:26 +08:00
|
|
|
Size resourceSize = Size(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
|
|
|
}
|
|
|
|
|
2013-07-12 13:11:21 +08:00
|
|
|
EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene * pScene = Scene::create();
|
|
|
|
Layer * pLayer = new TestController();
|
2012-04-19 14:35:52 +08:00
|
|
|
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()
|
|
|
|
{
|
2013-07-12 06:24:23 +08:00
|
|
|
Director::getInstance()->stopAnimation();
|
2013-07-19 07:30:19 +08:00
|
|
|
SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
|
|
|
|
SimpleAudioEngine::getInstance()->pauseAllEffects();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// this function will be called when the app is active again
|
|
|
|
void AppDelegate::applicationWillEnterForeground()
|
|
|
|
{
|
2013-07-12 06:24:23 +08:00
|
|
|
Director::getInstance()->startAnimation();
|
2013-07-19 07:30:19 +08:00
|
|
|
SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
|
|
|
|
SimpleAudioEngine::getInstance()->resumeAllEffects();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|