-
-
Save tks2shimizu/b48b377e817245f7d8a9 to your computer and use it in GitHub Desktop.
NyanRun (1)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// AppDelegate.cpp | |
// nyanrun | |
// | |
// Created by Tomoaki Shimizu on 2013/02/05. | |
// Copyright TKS2 2013. All rights reserved. | |
// | |
#include "AppDelegate.h" | |
#include "cocos2d.h" | |
#include "cocos-ext.h" | |
#include "SimpleAudioEngine.h" | |
USING_NS_CC; | |
USING_NS_CC_EXT; | |
using namespace CocosDenshion; | |
using namespace std; | |
AppDelegate::AppDelegate() | |
{ | |
} | |
AppDelegate::~AppDelegate() | |
{ | |
} | |
bool AppDelegate::applicationDidFinishLaunching() | |
{ | |
CCDirector* pDirector = CCDirector::sharedDirector(); | |
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); | |
pDirector->setDisplayStats(true); | |
pDirector->setAnimationInterval(1.0 / 60); | |
CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary(); | |
CCBReader * ccbReader = new CCBReader(ccNodeLoaderLibrary); | |
CCNode* node = ccbReader->readNodeGraphFromFile("GameLayer.ccbi"); | |
CCScene * scene = CCScene::create(); | |
if(node != NULL) | |
scene->addChild(node); | |
ccbReader->release(); | |
CCDirector::sharedDirector()->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() | |
{ | |
CCDirector::sharedDirector()->stopAnimation(); | |
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); | |
SimpleAudioEngine::sharedEngine()->pauseAllEffects(); | |
} | |
// this function will be called when the app is active again | |
void AppDelegate::applicationWillEnterForeground() | |
{ | |
CCDirector::sharedDirector()->startAnimation(); | |
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); | |
SimpleAudioEngine::sharedEngine()->resumeAllEffects(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment