日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

版本效果MoonWarrior cocos2d-x版本 --1

發布時間:2025/7/14 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 版本效果MoonWarrior cocos2d-x版本 --1 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章結束給大家來個程序員笑話:[M]

????網上似乎有這個版本了,但是人家是人家做的,自己動手敲一遍代碼感覺還是不一樣的

????MoonWarrior cocos2d-x里頭是用JS綁定來實現的,效果寫的還挺好的,麻雀雖小五臟俱全,改成C++,既熟習了cocos2d-x,也復習了前段時間學的js

????把win32的環境搭建好當前,新建一個cocos2d-x的工程,這篇就寫Menu吧

????新建一個類,繼承自CCLayer,

????需要寫兩行代碼

virtual bool init();CREATE_FUNC(LoadingScene);

????CREATE_FUNC是個宏定義,就是實現了create的方法,而create方法會調用init方法來初始化

bool bRet = false;do{//// super init first//CC_BREAK_IF(! CCLayer::init());CCSize winSize = CCDirector::sharedDirector()->getWinSize(); //加了兩個圖片進來CCSprite* background = CCSprite::create("loading.png");background->setAnchorPoint(ccp(0,0));this->addChild(background,0,1);CCSprite* logo = CCSprite::create("logo.png");logo->setAnchorPoint(ccp(0,0));logo->setPosition(ccp(0,250));this->addChild(logo,10,1); //三個menu進來,menu也是有狀態的,直接就能夠生成了CCSprite* newGameNormal = CCSprite::create("menu.png",CCRectMake(0, 0, 126, 33));//cc.Sprite.create(s_menu, cc.rect(0, 0, 126, 33));CCSprite* newGameSelected = CCSprite::create("menu.png", CCRectMake(0, 33, 126, 33));CCSprite* newGameDisabled = CCSprite::create("menu.png", CCRectMake(0, 33 * 2, 126, 33));CCSprite* gameSettingsNormal = CCSprite::create("menu.png", CCRectMake(126, 0, 126, 33));CCSprite* gameSettingsSelected = CCSprite::create("menu.png", CCRectMake(126, 33, 126, 33));CCSprite* gameSettingsDisabled = CCSprite::create("menu.png", CCRectMake(126, 33 * 2, 126, 33));CCSprite* aboutNormal = CCSprite::create("menu.png", CCRectMake(252, 0, 126, 33));CCSprite* aboutSelected = CCSprite::create("menu.png", CCRectMake(252, 33, 126, 33));CCSprite* aboutDisabled = CCSprite::create("menu.png", CCRectMake(252, 33 * 2, 126, 33));CCMenuItem* newGame = CCMenuItemSprite::create(newGameNormal,newGameSelected,newGameDisabled,this,menu_selector(LoadingSense::newGameCallback));CCMenuItem* gameSettings = CCMenuItemSprite::create(gameSettingsNormal,gameSettingsSelected,gameSettingsDisabled,this,menu_selector(LoadingSense::onSettings));CCMenuItem* about = CCMenuItemSprite::create(aboutNormal,aboutSelected,aboutDisabled,this,menu_selector(LoadingSense::onAbout));//cc.MenuItemSprite.create(aboutNormal, aboutSelected, aboutDisabled, this, this.onAbout);CCMenu* menu = CCMenu::create(newGame,gameSettings,about,NULL);//CCMenu::create(newGame, gameSettings, about);menu->alignItemsVerticallyWithPadding(10);this->addChild(menu, 1, 2);menu->setPosition(ccp(winSize.width / 2, winSize.height / 2 - 80)); 每日一道理
天又快黑了,這座忙碌的城市又將入睡,讓這勞累的“身軀”暫別白日的辛勤,讓它入睡,陪伴著城市中的人們進入夢鄉。當空的彎月正深情地注視著這座城市與城市中的人們,看著家家戶戶的燈漸漸熄滅,它在床頭悄悄奏響“明月曲”……
//這個schedule是讓背景的那個小飛機飛到頂端了,還能從下面接著飛//this->schedulethis->schedule(schedule_selector(LoadingSense::update), 0.1);CCTexture2D* tmp = CCTextureCache::sharedTextureCache()->addImage("ship01.png");m_pShip = CCSprite::createWithTexture(tmp,CCRectMake(0, 45, 60, 38));this->addChild(m_pShip,0,4);CCPoint pos = ccp(((float)(rand()%10)/10)*winSize.width, 0); //讓飛機從底下飛到上邊m_pShip->setPosition(pos);//m_pShip->setPosition(ccp(100,100));m_pShip->runAction(CCMoveBy::create(2,ccp(((float)(rand()%10)/10)*winSize.width,pos.y+winSize.height + 100)));//m_pShip->runAction(CCMoveBy::create(2,ccp(200,200))); //播放音樂if(true){CocosDenshion::SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(0.7);CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic(s_mainMainMusic,true);}bRet = true;}while(0);return bRet;

????
轉一篇關于錨點的?http://blog.csdn.net/cjopengler/article/details/7045638

????基本的都有了,下面再看一個動畫效果,點擊new game當前,會有一個效果,看看這個效果怎么做的

CCSprite* flare = CCSprite::create("flare.jpg");ccBlendFunc ccBF = {GL_SRC_ALPHA, GL_ONE}; flare->setBlendFunc(ccBF);parent->addChild(flare, 10);flare->setOpacity(0);flare->setPosition(ccp(-30, 297));flare->setRotation(-120);flare->setScale(0.2);CCFadeTo* opacityAnim = CCFadeTo::create(0.5, 255);CCFadeTo* opacDim = CCFadeTo::create(1, 0);CCScaleBy* biggeAnim = CCScaleBy::create(0.7, 1.2, 1.2);CCEaseSineOut* biggerEase = CCEaseSineOut::create(biggeAnim);CCMoveBy* moveAnim = CCMoveBy::create(0.5, ccp(328, 0));CCEaseSineOut* easeMove = CCEaseSineOut::create(moveAnim);CCRotateBy* rotateAnim = CCRotateBy::create(2.5, 90);CCEaseExponentialOut* rotateEase = CCEaseExponentialOut::create(rotateAnim);CCScaleTo* bigger = CCScaleTo::create(0.5, 1);CCCallFunc* onComplete = CCCallFunc::create(target, callback);CCCallFunc* killflare = CCCallFunc::create(target, callfunc_selector(LoadingSense::killFlare));flare->runAction(CCSequence::create(opacityAnim, biggerEase, opacDim, killflare, onComplete,NULL));flare->runAction(easeMove);flare->runAction(rotateEase);flare->runAction(bigger);

????
關于cocos2d-x的動畫,簡單點的可以看http://blog.csdn.net/odustggg/article/details/8187843

????

????這樣背景 菜單 點擊newGame以后的動畫效果都就有了,后面就是該做游戲的重頭戲了

????

????

????

????

????

文章結束給大家分享下程序員的一些笑話語錄: 面試官:熟悉哪種語言
應聘者:JAVA
面試官:知道什么叫類么
應聘者:我這人實在,工作努力,不知道什么叫累
面試官:知道什么是包?
應聘者:我這人實在 平常不帶包 也不用公司準備了
面試官:知道什么是接口嗎?
應聘者:我這個人工作認真。從來不找借口偷懶
面試官:知道什么是繼承么
應聘者:我是孤兒沒什么可以繼承的
面試官:知道什么叫對象么?
應聘者:知道,不過我工作努力,上進心強,暫時還沒有打算找對象。
面試官:知道多態么?
應聘者:知道,我很保守的。我認為讓心愛的女人為了自已一時的快樂去墮胎是不道德的行為!請問這和C#有什么關系??

--------------------------------- 原創文章 By
版本和效果
---------------------------------

總結

以上是生活随笔為你收集整理的版本效果MoonWarrior cocos2d-x版本 --1的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。