資源簡介
Vs2013+cocos2dx貪吃蛇,3個場景的切換,代碼有注釋

代碼片段和文件信息
#include?“AppDelegate.h“
#include?“HomeScene.h“
USING_NS_CC;
AppDelegate::AppDelegate()?{
}
AppDelegate::~AppDelegate()?
{
}
//if?you?want?a?different?contextjust?modify?the?value?of?glContextAttrs
//it?will?takes?effect?on?all?platforms
void?AppDelegate::initGLContextAttrs()
{
????//set?OpenGL?context?attributionsnow?can?only?set?six?attributions:
????//redgreenbluealphadepthstencil
????GLContextAttrs?glContextAttrs?=?{8?8?8?8?24?8};
????GLView::setGLContextAttrs(glContextAttrs);
}
//?If?you?want?to?use?packages?manager?to?install?more?packages?
//?don‘t?modify?or?remove?this?function
static?int?register_all_packages()
{
????return?0;?//flag?for?packages?manager
}
bool?AppDelegate::applicationDidFinishLaunching()?{
????//?initialize?director
????auto?director?=?Director::getInstance();
????auto?glview?=?director->getOpenGLView();
????if(!glview)?{
????????glview?=?GLViewImpl::create(“My?Game“);
????????director->setOpenGLView(glview);
????}
????//?turn?on?display?FPS
????director->setDisplayStats(true);
????//?set?FPS.?the?default?value?is?1.0/60?if?you?don‘t?call?this
????director->setAnimationInterval(1.0?/?60);
????register_all_packages();
????//?create?a?scene.?it‘s?an?autorelease?object
????auto?scene?=?HomeScene::CreateScene();
????//?run
????director->runWithScene(scene);
????return?true;
}
//?This?function?will?be?called?when?the?app?is?inactive.?When?comes?a?phone?callit‘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();
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-07-10?23:57??snake\
?????文件????????1959??2016-07-11?20:43??snake\AppDelegate.cpp
?????文件?????????987??2016-07-10?02:15??snake\AppDelegate.h
?????文件??????120252??2016-07-10?11:46??snake\apple.png
?????文件????????1454??2016-07-12?00:07??snake\GameOverScene.cpp
?????文件?????????282??2016-07-11?20:55??snake\GameOverScene.h
?????文件????????6062??2016-07-11?23:50??snake\HelloWorldScene.cpp
?????文件????????1473??2016-07-12?00:07??snake\HelloWorldScene.h
?????文件????????1103??2016-07-12?00:07??snake\HomeScene.cpp
?????文件?????????180??2016-07-11?20:34??snake\HomeScene.h
?????文件????????1941??2016-07-12?00:09??snake\SnakeSprite.cpp
?????文件?????????800??2016-07-12?00:07??snake\SnakeSprite.h
- 上一篇:ssh+jbpm項目某集團OA
- 下一篇:改進粒子群算法對BP神經網絡的優化
評論
共有 條評論