/
AppDelegate.cpp
110 lines (69 loc) · 2.45 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "AppDelegate.h"
#include "HelloWorldScene.h"
USING_NS_CC;
AppDelegate::AppDelegate() {
}
AppDelegate::~AppDelegate()
{
}
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
glview = GLView::create("aplicacion X");
glview->setFrameSize(480, 800);
director->setOpenGLView(glview);
}
// turn on display FPS
director->setDisplayStats(false);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
auto fileUtils = FileUtils::getInstance();
auto screenSize = glview->getFrameSize();
std::vector<std::string> resDirOrder;
// vrificamos los deistintos dispositivos.
if( 2048 == screenSize.width || 2048 ==screenSize.height )
{
resDirOrder.push_back("default");
glview->setDesignResolutionSize(2048,1536, ResolutionPolicy::NO_BORDER);
}
else if(1024 == screenSize.width || 1024 == screenSize.height)
{
resDirOrder.push_back("default2");
glview->setDesignResolutionSize(1024, 768, ResolutionPolicy::NO_BORDER);
}
else if(1136 == screenSize.width || 1136 == screenSize.height)
{
resDirOrder.push_back("default");
glview->setDesignResolutionSize(1136, 640, ResolutionPolicy::NO_BORDER);
}
else if(960 == screenSize.width || 960 == screenSize.height)
{
resDirOrder.push_back("default");
glview->setDesignResolutionSize(960, 640, ResolutionPolicy::NO_BORDER);
}
else
{
resDirOrder.push_back("default");
glview->setDesignResolutionSize(380, 650, ResolutionPolicy::NO_BORDER);
}
fileUtils->setSearchPaths(resDirOrder);
// create a scene. it's an autorelease object
auto scene = HelloWorld::createScene();
// run
director->runWithScene(scene);
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() {
Director::getInstance()->stopAnimation();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() {
Director::getInstance()->startAnimation();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
}