forked from alldnnwanglu/PopoStar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppDelegate.cpp
81 lines (66 loc) · 2.42 KB
/
AppDelegate.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "AppDelegate.h"
#include "GameMenuScene.h"
#include "GameMainScene.h"
#include "UIManager.h"
#include "MusicManager.h"
#if defined( PAY_WITH_UMENG )
#include "MobClickCpp.h"
#endif
USING_NS_CC;
AppDelegate::AppDelegate() {
}
AppDelegate::~AppDelegate()
{
}
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
CCDirector* pDirector = CCDirector::sharedDirector();
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
pDirector->setOpenGLView(pEGLView);
pEGLView->setDesignResolutionSize( 480, 854, kResolutionShowAll );
// turn on display FPS
//pDirector->setDisplayStats(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 = GameMenuScene::scene();// HelloWorld::scene();
//CCScene *pScene = GameMainScene::scene();
// run
pDirector->runWithScene(pScene);
CCDictionary* dic = CCDictionary::createWithContentsOfFile( "cn.xml" );
CCString* strChannel = (CCString*)dic->objectForKey("channelId");
#if defined( PAY_WITH_UMENG )
MOBCLICKCPP_START_WITH_APPKEY_AND_CHANNEL("5513cc34fd98c5ce0800048f", strChannel->getCString());
#endif
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() {
CCDirector::sharedDirector()->stopAnimation();
if (MusicManager::GetInstance() != NULL)
{
MusicManager::GetInstance()->Stop();
}
#if defined( PAY_WITH_UMENG )
umeng::MobClickCpp::applicationDidEnterBackground();
#endif
// if you use SimpleAudioEngine, it must be pause
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() {
CCDirector::sharedDirector()->startAnimation();
bool musicStoped = CCUserDefault::sharedUserDefault()->getBoolForKey("musicStop");
if (MusicManager::GetInstance() != NULL && !musicStoped)
{
MusicManager::GetInstance()->Open();
}
if(UIManager::GetInstance()->getStopMenuUI()!=NULL)
{
UIManager::GetInstance()->getStopMenuUI()->activate();
}
#if defined( PAY_WITH_UMENG )
umeng::MobClickCpp::applicationWillEnterForeground();
#endif
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}