|
@@ -1,20 +1,16 @@
|
|
|
+
|
|
|
+ * Nomes: Gabriel Capella Números USP: 8962078
|
|
|
+ * João Herique Luciano 8535957
|
|
|
+ *
|
|
|
+ * Tarefa: RedCore - EP2 MAC0463
|
|
|
+ * Arquivo: AppDelegate.cpp
|
|
|
+ * Descrição: Classe para inicializar jogo. Padrão da biblioteca.
|
|
|
+ ********************************************************************/
|
|
|
+
|
|
|
#include "AppDelegate.h"
|
|
|
#include "BeginScene.h"
|
|
|
-
|
|
|
-
|
|
|
-#define USE_SIMPLE_AUDIO_ENGINE 1
|
|
|
-
|
|
|
-#if USE_AUDIO_ENGINE && USE_SIMPLE_AUDIO_ENGINE
|
|
|
-#error "Don't use AudioEngine and SimpleAudioEngine at the same time. Please just select one in your game!"
|
|
|
-#endif
|
|
|
-
|
|
|
-#if USE_AUDIO_ENGINE
|
|
|
-#include "audio/include/AudioEngine.h"
|
|
|
-using namespace cocos2d::experimental;
|
|
|
-#elif USE_SIMPLE_AUDIO_ENGINE
|
|
|
#include "audio/include/SimpleAudioEngine.h"
|
|
|
using namespace CocosDenshion;
|
|
|
-#endif
|
|
|
|
|
|
USING_NS_CC;
|
|
|
|
|
@@ -24,15 +20,9 @@ AppDelegate::AppDelegate() {
|
|
|
}
|
|
|
|
|
|
AppDelegate::~AppDelegate() {
|
|
|
-#if USE_AUDIO_ENGINE
|
|
|
- AudioEngine::end();
|
|
|
-#elif USE_SIMPLE_AUDIO_ENGINE
|
|
|
SimpleAudioEngine::end();
|
|
|
-#endif
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
void AppDelegate::initGLContextAttrs() {
|
|
|
|
|
|
GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
|
|
@@ -50,72 +40,56 @@ bool AppDelegate::applicationDidFinishLaunching() {
|
|
|
auto director = Director::getInstance();
|
|
|
auto glview = director->getOpenGLView();
|
|
|
if(!glview) {
|
|
|
-#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
|
|
|
- director->setContentScaleFactor(2);
|
|
|
- glview = GLViewImpl::createWithRect("RedCore", cocos2d::Rect(0, 0, designResolutionSize.width, designResolutionSize.height));
|
|
|
-#else
|
|
|
+
|
|
|
+
|
|
|
+ #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
|
|
|
+ director->setContentScaleFactor(2);
|
|
|
+ glview = GLViewImpl::createWithRect(
|
|
|
+ "RedCore",
|
|
|
+ cocos2d::Rect(0, 0, designResolutionSize.width, designResolutionSize.height)
|
|
|
+ );
|
|
|
+ #else
|
|
|
glview = GLViewImpl::create("RedCore");
|
|
|
-#endif
|
|
|
+ #endif
|
|
|
+
|
|
|
director->setOpenGLView(glview);
|
|
|
}
|
|
|
|
|
|
|
|
|
-#if DEBUG
|
|
|
+ #if DEBUG
|
|
|
director->setDisplayStats(true);
|
|
|
-#endif
|
|
|
+ #endif
|
|
|
|
|
|
|
|
|
director->setAnimationInterval(1.0f / 60);
|
|
|
|
|
|
|
|
|
- glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);
|
|
|
- auto frameSize = glview->getFrameSize();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ glview->setDesignResolutionSize(
|
|
|
+ designResolutionSize.width,
|
|
|
+ designResolutionSize.height,
|
|
|
+ ResolutionPolicy::NO_BORDER
|
|
|
+ );
|
|
|
|
|
|
register_all_packages();
|
|
|
|
|
|
-
|
|
|
Scene* scene = BeginScene::createScene();
|
|
|
director->runWithScene(scene);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+ * receiving a phone call it is invoked.
|
|
|
+ * */
|
|
|
void AppDelegate::applicationDidEnterBackground() {
|
|
|
Director::getInstance()->stopAnimation();
|
|
|
-
|
|
|
-#if USE_AUDIO_ENGINE
|
|
|
- AudioEngine::pauseAll();
|
|
|
-#elif USE_SIMPLE_AUDIO_ENGINE
|
|
|
SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
|
|
|
SimpleAudioEngine::getInstance()->pauseAllEffects();
|
|
|
-#endif
|
|
|
}
|
|
|
|
|
|
|
|
|
void AppDelegate::applicationWillEnterForeground() {
|
|
|
Director::getInstance()->startAnimation();
|
|
|
-
|
|
|
-#if USE_AUDIO_ENGINE
|
|
|
- AudioEngine::resumeAll();
|
|
|
-#elif USE_SIMPLE_AUDIO_ENGINE
|
|
|
SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
|
|
|
SimpleAudioEngine::getInstance()->resumeAllEffects();
|
|
|
-#endif
|
|
|
}
|