bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

三:cocos2d-x代碼分析-創(chuàng)新互聯(lián)

目錄結(jié)構(gòu):

目前創(chuàng)新互聯(lián)公司已為成百上千的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬空間、網(wǎng)站托管維護(hù)、企業(yè)網(wǎng)站設(shè)計(jì)、杜爾伯特網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。

Box2D
 物理引擎Box2D的相關(guān)文件
Chipmunk物理引擎Chipmunk的相關(guān)文件
cocos2dxcocos2d-x引擎的核心,存放引擎的大部分源文件
CocosDenshion音頻模塊相關(guān)源文件
Debug.win32 在Windows上的調(diào)試輸出目錄
Doxygen生成doxygen項(xiàng)目文檔時(shí)需要的配置文件
HelloWorldHelloWorld的源代碼
Hellolualua的示例代碼
Lua lua腳本支持的源碼
JsJs腳本支持的源碼
Licences許可文件的目錄
Template包括編譯Ios和Android平臺(tái)開發(fā)時(shí)的配置文件
testjs
cocos2d-x引擎js語(yǔ)言的API示例代碼
testscocos2d-x引擎的所有API示例代碼
Tools包括“Tolua的配置文件”和“Xcode4的模版生成工具”


1.類AppDelegate  //控制游戲生命周期

類AppDelegate繼承了CCApplication,定義了三個(gè)方法:

        virtualbool applicationDidFinishLaunching();     //響應(yīng)窗口啟動(dòng)完成后的工作

        virtualvoid applicationDidEnterBackground();     //響應(yīng)窗口進(jìn)入后臺(tái)的工作

        virtualvoid applicationWillEnterForeground();      //響應(yīng)窗口從后臺(tái)恢復(fù)的工作

   I  啟動(dòng)時(shí)初始化的工作

  1. bool AppDelegate::applicationDidFinishLaunching()

  2. {

  3.   // initialize Director

  4.   CCDirector* pDirector =CCDirector::sharedDirector();  // 場(chǎng)景管理器

  5.   CCEGLView* pEGLView =CCEGLView::sharedOpenGLView();  //創(chuàng)建視口

  6.   pDirector->setOpenGLView(pEGLView);      //設(shè)置OpenGL視口

  7.   // Set the design resolution

  8.   pEGLView->setDesignResolutionSize(designResolutionSize.width,designResolutionSize.height, kResolutionNoBorder);   //設(shè)置分辨率大小

  9.   CCSize frameSize =pEGLView->getFrameSize();

  10.   vector<string> searchPath;      //資源路徑

  11.  //在不同的平臺(tái)下加載不同的資源

  12.   if (frameSize.height> mediumResource.size.height)

  13.   {

  14.     searchPath.push_back(largeResource.directory);

  15.     pDirector->setContentScaleFactor(MIN(largeResource.size.height/designResolutionSize.height,largeResource.size.width/designResolutionSize.width));

  16.   }

  17.   // if the frame'sheight is larger than the height of small resource size, select mediumresource.

  18.   else  if (frameSize.height > smallResource.size.height)

  19.   {

  20.     searchPath.push_back(mediumResource.directory);

  21.     pDirector->setContentScaleFactor(MIN(mediumResource.size.height/designResolutionSize.height,mediumResource.size.width/designResolutionSize.width));

  22.   }

  23.   // if the frame's height is smaller than the height of medium resource size, select smallresource.

  24.   else

  25.   {

  26.     searchPath.push_back(smallResource.directory);

  27.     pDirector->setContentScaleFactor(MIN( smallResource.size.height/designResolutionSize.height , smallResource.size.width/designResolutionSize.width ) );

  28.   }

  29.  //設(shè)置資源文件路徑

  30.   CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);

  31.   // turn ondisplay FPS

  32.   pDirector->setDisplayStats(true);   //開啟顯示FPS

  33.   // set FPS. the default value is 1.0/60 if you don't call this

  34.   pDirector->setAnimationInterval(1.0 /60);  // 設(shè)置幀速率 ,最好不要低于30幀

  35.   // create a scene. it's an autorelease object

  36.   CCScene *pScene = HelloWorld::scene();    //調(diào)用靜態(tài)方法創(chuàng)建一個(gè)場(chǎng)景,HelloWorld中會(huì)負(fù)責(zé)場(chǎng)景的實(shí)現(xiàn)

  37.   pDirector->runWithScene(pScene);    //導(dǎo)演調(diào)用,運(yùn)行HelloWorld中的場(chǎng)景。

  38.   return  true;

  39. }

II  暫停動(dòng)作

  1. // This function will be called when the app is inactive. When comes a phone call,it's be invoked too

  2. void AppDelegate::applicationDidEnterBackground()

  3. {

  4.   CCDirector::sharedDirector()->stopAnimation();   //暫停活動(dòng)

  5.   // if you use SimpleAudioEngine, it must be pause

  6.   // SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();  //暫停背景音樂(lè)

  7. }

III  恢復(fù)動(dòng)作

  1. // this function will be called when the app is active again

  2. void AppDelegate::applicationWillEnterForeground()

  3. {

  4.   CCDirector::sharedDirector()->startAnimation();  // 恢復(fù)活動(dòng)

  5.   // if you use SimpleAudioEngine, it must resume here

  6.   // SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();  // 恢復(fù)背景音樂(lè)

  7. }

2.HelloWorld

  1. CCScene*HelloWorld::scene()

  2. {

  3.   // 'scene' is an autorelease object

  4.   CCScene *scene = CCScene::create();   //創(chuàng)建場(chǎng)景

  5.   // 'layer' is an autorelease object

  6.   HelloWorld *layer = HelloWorld::create();   //創(chuàng)建圖層

  7.   // add layer as achild to scene

  8.   scene->addChild(layer);          //添加圖層作為節(jié)點(diǎn)

  9.   // return the scene

  10.   return scene;

  11. }

  12. bool HelloWorld::init()

  13. {

  14.   // 1. super initfirst

  15.   if (!CCLayer::init() )   //創(chuàng)建圖層

  16.   {

  17.     return  false;

  18.   }

  19.   CCSize visibleSize =CCDirector::sharedDirector()->getVisibleSize();       //獲取大小

  20.   CCPoint origin =CCDirector::sharedDirector()->getVisibleOrigin();      //獲取原點(diǎn),原點(diǎn)(origin.x , origin.y)在左下角

  21.   CCMenuItemImage *pCloseItem =CCMenuItemImage::create( "CloseNormal.png, "CloseSelected.png",  this,

  22.        menu_selector( HelloWorld::menuCloseCallback ) );      //創(chuàng)建關(guān)閉按鈕 ,在這里的圖片路徑如果不是在/Resources 目錄下,則圖片不能使用。  如果要在Resources目下放置文件夾,則需要在字符串中加入路徑名稱,如”/raster-32x32/ 32x32.png“

  23. //設(shè)置按鈕位置,可以看出 Cocos2d-x的坐標(biāo)原點(diǎn)是左下角

  24. pCloseItem->setPosition(ccp(origin.x+ visibleSize.width - pCloseItem->getContentSize().width/2 ,

  25.                 origin.y +pCloseItem->getContentSize().height/2));

  26. //   visibleSize.width                       屏幕的寬度

  27. //   pCloseItem->getContentSize().width/2   是圖片寬度的1/2

  28. //  pCloseItem->getContentSize().height/2  是圖片高度的1/2

  29. //    pCloseItem->setPosition(ccp(origin.x ,  origin.y ) );  // pCloseItem的坐標(biāo)設(shè)置是以默認(rèn)錨點(diǎn)為坐標(biāo)中心,即錨點(diǎn)在(0,0),此時(shí)按鈕只能顯示1/4

  30.  //創(chuàng)建菜單,將關(guān)閉按鈕加入到菜單項(xiàng)

  31.   CCMenu* pMenu = CCMenu::create(pCloseItem,NULL);

  32.   pMenu->setPosition(CCPointZero);   //  設(shè)置菜單的位置

  33.   this->addChild(pMenu,1);           //  將菜單加入到HelloWorld圖層中

  34.   //創(chuàng)建 HelloWorld 文本

  35.   CCLabelTTF* pLabel = CCLabelTTF::create("Hello World","Arial",TITLE_FONT_SIZE);

  36.   // position thelabel on the center of the screen

  37.   pLabel->setPosition(ccp(origin.x +visibleSize.width/2,

  38.               origin.y +visibleSize.height - pLabel->getContentSize().height));  //設(shè)置文本(Label)的位置 ,坐標(biāo)是字符串中心的坐標(biāo),并不是最開始的位置

  39.   // add the labelas a child to this layer

  40.   this->addChild(pLabel,1);   //  將文本(Label)加入到HelloWorld圖層中

  41.   //創(chuàng)建精靈圖片

  42.   CCSprite* pSprite = CCSprite::create("HelloWorld.png");

  43.   // position thesprite on the center of the screen

  44.   pSprite->setPosition(ccp(visibleSize.width/2 + origin.x,visibleSize.height/2 + origin.y));   // 設(shè)置圖片精靈的位置

  45.   // add the spriteas a child to this layer

  46.   this->addChild(pSprite,0);    //  將圖片精靈加入到HelloWorld圖層中  (第二個(gè)參數(shù)是Z軸坐標(biāo):0在底層,1在上層  。  Z軸坐標(biāo)系參考笛卡爾右手坐標(biāo)系(正方向:x軸向右,y軸向上,z軸向外)

  47. //設(shè)置為相同的Z軸坐標(biāo)時(shí),按加載順序顯示,先加載的先顯示,后加載的后顯示

  48.   return  true;

  49.  }

IIII  點(diǎn)擊按鈕結(jié)束的回調(diào)函數(shù)

  1. void HelloWorld::menuCloseCallback(CCObject* pSender)

  2. {

  3. #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)

  4. CCMessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");

  5. #else

  6.   CCDirector::sharedDirector()->end();

  7. #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)

  8.   exit(0);

  9. #endif

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

當(dāng)前名稱:三:cocos2d-x代碼分析-創(chuàng)新互聯(lián)
瀏覽路徑:http://vcdvsql.cn/article38/cscisp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)外貿(mào)網(wǎng)站建設(shè)虛擬主機(jī)企業(yè)建站品牌網(wǎng)站設(shè)計(jì)企業(yè)網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)