Skip to content

Instantly share code, notes, and snippets.

@tks2shimizu
Last active December 12, 2015 04:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tks2shimizu/b48b377e817245f7d8a9 to your computer and use it in GitHub Desktop.
Save tks2shimizu/b48b377e817245f7d8a9 to your computer and use it in GitHub Desktop.
NyanRun (1)
//
// 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