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-06-20 14:17:10 +08:00
|
|
|
Configuration::sharedConfiguration()->loadConfigFile("configs/config-example.plist");
|
2013-06-07 03:23:44 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// initialize director
|
2013-06-20 14:17:10 +08:00
|
|
|
Director *pDirector = Director::sharedDirector();
|
|
|
|
pDirector->setOpenGLView(EGLView::sharedOpenGLView());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size screenSize = EGLView::sharedOpenGLView()->getFrameSize();
|
2012-08-23 14:20:32 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size designSize = CCSizeMake(480, 320);
|
2013-06-09 18:54:35 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
FileUtils* pFileUtils = FileUtils::sharedFileUtils();
|
2012-10-23 17:48:50 +08:00
|
|
|
|
|
|
|
if (screenSize.height > 320)
|
2012-10-12 17:37:26 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Size 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
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
EGLView::sharedOpenGLView()->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-06-20 14:17:10 +08:00
|
|
|
Director::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()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Director::sharedDirector()->startAnimation();
|
2012-04-19 14:35:52 +08:00
|
|
|
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
|
|
|
|
SimpleAudioEngine::sharedEngine()->resumeAllEffects();
|
|
|
|
}
|