




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、捕魚達(dá)人項(xiàng)目開(kāi)發(fā)過(guò)程文檔一、游戲資源文件UI圖片image圖片:包括火炮,魚,子彈,漁網(wǎng),金幣,數(shù)字,背景圖片以及其它CCFish類:實(shí)現(xiàn)魚的曲線路線的移動(dòng)與各種魚捕捉概率的設(shè)置UINumber 類與 UIRollNumber 類二、游戲基本結(jié)構(gòu)確定及搭建SysMenu(scene)GameMain(scene)Setting(layer)Help(scene)圖1.1依次在項(xiàng)目中創(chuàng)建如有圖類完成項(xiàng)目結(jié)構(gòu),在總體上把握項(xiàng)目實(shí)現(xiàn)內(nèi)容、詳細(xì)設(shè)計(jì)與各功能模塊的實(shí)現(xiàn)程序編寫流程1.系統(tǒng)菜單場(chǎng)景:1)2)3)添加初始化方法添加菜單添加菜單選項(xiàng)方法2.游戲場(chǎng)景1)2)3)4)5)6)添加初始化方法添加紋理
2、圖集載入方法添加UI設(shè)計(jì)方法添加觸摸事件處理方法 添加自動(dòng)補(bǔ)充魚更新方法 添加碰撞檢測(cè)方法二 1 Twr.EL 805 SDK E ClMsihwiig-kla iter L_ 熱i TSer(h|hSc ttin t; LJive r .mh| GBrtiiMainLjavtr.h e| GiimrMdfcmLiviFi mh j UHMLiinrbeF h m UlMLi-rirber m h|1叫5根M用UE,E h | 匚匚匚口 Rmsn.fi e| CCCar*ion.h| CCNeth aril CCNec h| CCVyllfeT h 川 CSuIbctE lh| 匚UFIssh
3、.hh 9八Mn| Si-Mcnu e h A SpOi l-e qan- a n m 科口01七華1虻M hl r. hReS-DluTCJE-S3.4.設(shè)置頁(yè)面幫助場(chǎng)景游戲重要模塊詳細(xì)實(shí)現(xiàn)1 .紋理圖集的使用與加載要點(diǎn):精靈處于界面中的層次關(guān)系,如下為紋理圖集加載代碼CCSpriteFrameCache sharedSpriteFrameCache addSpriteFramesWithFile :fish.plist;fishSheet = CCSpriteBatchNode batchNodeWithFile :fish.png;self addChild :fishSheet z:1
4、00;2 . UI設(shè)計(jì)的細(xì)節(jié)實(shí)現(xiàn)要點(diǎn):各個(gè) UI部件(精靈)的層次,位置調(diào)整以及武器的更換動(dòng)作設(shè)置,下面為UI實(shí)現(xiàn)代碼-(void) initUI |CGSize winSize = CCDirector sharedDirector winSize;CCSprite * background = CCSprite spriteWithFile :bj00.jpg;background. position = ccp(winSize. width * 0.5, winSize. height * 0.5);self addChild :background z:0;添加能量槽CCSprite
5、*engryBox = CCSprite spriteWithFile :ui_2p_004.png;engryBox. anchorPoint = ccp(0.5,0.5);engryBox. position = ccp (winSize. width /2,10);self addChild :engryBox z:10; |添加能量箭頭energyPointer = CCSprite spriteWithFile :ui_2p_005.png;energyPointer .anchorPoint = ccp (0.5,0.5);energyPointer .position = ccp
6、(winSize. width/2,10);energyPointer .rotation = minEnergyRotation ;self addChild :energyPointer z:12;|添加頂部框體CCSprite *bgExp = CCSprite spriteWithFile :ui_box_01.png;bgExp. position = ccp(winSize. width/2, winSize. height);bgExp. anchorPoint = ccp(0.5f ,1.0f);self addChild :bgExp z:101;添加底框CCSprite *
7、bgNum = CCSprite spriteWithFile :ui_box_02.png;bgNum. position = ccp(bgNum.contentSize. width/2, 0);bgNum. anchorPoint = ccp(0.5f,0);self addChild :bgNum z:101;添加武器cannnon = CCCannon spriteWithSpriteFrameName : NSStringstringWithFormat :actor_cannon1_%i1.png ,1;cannnon .cannonLevel = 1;cannonLevel =
8、 1;cannnon .anchorPoint = ccp(0.5f,0.5f);cannnon .position = ccp (winSize. width/2,30);cannnon .scale = cannon_scale ;cannnon .cannonType = nomal;cannonSheet addChild :cannnon ;|/添加牛,上按鈕(待改)CCMenultemFont setFontSize :32;CCMenultemFont setFontName :Arial;CCMenultem * addItem = CCMenultemFont itemFro
9、mString : + target:self elector :selector (addCannonLeave); |/addItem.scale = 1.5;CCMenu * addMenu = CCMenu menuWithltems :addItem, nil;addMenu. position = ccp (winSize. width*0.5+30, 10);addMenu alignItemsVertically ;self addChild :addMenu z:102 ;CCMenuItem * reduceltem = CCMenuItemFont itemFromStr
10、ing : - target:self | selector: selector (reduceCannonLeave); |CCMenu * reduceMenu = CCMenu menuWithltems :reduceltem, nil;reduceMenu. position = ccp (winSize. width*0.5-30, 10);reduceMenu alignltemsVertically ;self addChild :reduceMenu z:102 ;初始化金幣數(shù)gold = UlRollNumber allocinit;gold setNumber :orig
11、inGold ;gold setPosition :ccp(168, 10);self addChild :gold z:102 ;-(void )addCannonLeave |CGSize winSize = CCDirector sharedDirector winSize ;cannonLevel +;lf( cannonLevel = 8)cannonLevel = 1;/remove cannon |CCScaleTo * narrow = CCScaleT o actionWithDuration :0.1f scale :0.1;CCCallFuncO * removeCann
12、on = CCCallFuncO actionWithTarget :self selector:selector (removeCannon:) | object :cannnon ;CCSequence *bowDismissSequence = CCSequence actions :narrow,removeCannon, nil;cannnon runAction :bowDismissSequence; | /add a new cannon |cannnon = CCCannon spriteWithSpriteFrameName :NSString stringWithForm
13、at :actor_cannon1_%i1.png ,cannonLevel ; cannnon .cannonLevel = cannonLevel ;cannnon .position = ccp(winSize. width*0.5,30);cannnon .scale = 0.1f;CCDelayTime * delayTime = CCDelayTime actionWithDuration :0.1f;CCScaleTo * appear = CCScaleT o actionWithDuration :0.1f scale:cannon scale ;CCSequence * b
14、o = CCSequence actions :delayTime,appear, nil;cannnon runAction :bo;cannonSheet addChild :cannnon z: 100;刪除武器用于武器改變-(void )removeCannon:( id)sender | /CCLOG(removeBow); | CCCannon * sp = sender; cannonSheet removeChild :sp cleanup :YES;3.觸摸事件模塊要點(diǎn):子彈、大炮的跟隨轉(zhuǎn)向,子彈射出速度設(shè)置,越界判定(移動(dòng)出畫面)- (void) setAngle:( CG
15、Point )point sprite:( CCSprite *)sp /CCLOG(setAngle); |/設(shè)置旋轉(zhuǎn)角度”int offX = point. x - cannnon .position .x;int offY = point. y - cannnon . position .y;if (offY = 0) return ;float ratio = ( float)offY /(float )offX;/直角三角形float angle = atanf(ratio)/ M_PI *180;三角形正切值獲得角度if (angle 0) |cannnon . rotation
16、= 90 - angle; |sp. rotation = cannnon . rotation ;#pragma touch menthed- (void)ccTouchesBegan:( NSSet *)touches withEvent:( UIEvent *)event |for (UITouch *touch in touches) |CGPoint pos = touch locationInView :touch. view;pos = CCDirector sharedDirector convertToGL :pos;if (pos. y = cannnon .positio
17、n .y) return ;if (cannnon .cannonType = laser) 如果當(dāng)前為超級(jí)武器, else cannnon setDisplayFrame : CCSpriteFrameCache sharedSpriteFrameCache | spriteFrameByName :NSStringstringWithFormat :actor_cannon1_%i2.png ,cannnon .cannonLevel ;self setAngle :pos sprite :nil;- (void)ccTouchesMoved:( NSSet *)touches withE
18、vent:( UIEvent *)eventfor (UITouch *touch in touches) CGPoint pos = touch locationInView :touch. view;pos = CCDirector sharedDirector convertToGL :pos;self setAngle :pos sprite :nil;-(void)ccTouchesEnded:( NSSet *)touches withEvent:( UIEvent *)event|for (UITouch *touch in touches)CGSize winSize = CC
19、Director sharedDirector winSize;CGPoint pos = touch locationInView :touch. view;pos = CCDirector sharedDirector convertToGL :pos;int offX = pos. x - cannnon .position .x;int offY = pos. y - cannnon .position.y;if (offY = 0) return ;if(cannnon .cannonType = laser)用超級(jí)能量捕捉動(dòng)物(待改)cannnon .cannonType = no
20、mal; 發(fā)射完畢還原武器else*(待改)*gold setNumber :(gold getNumber -cannnon .cannonType );/每次損耗 CCBullet *bullet = CCBullet spriteWithSpriteFrameName :NSString | stringWithFormat :bullet0%i.png ,cannnon .cannonLevel ; 添加子彈 bullet. position = cannnon .position ;bullet. isHit = NO;self setAngle :pos sprite :bulle
21、t; |/ Determine where we wish to shoot the projectile to |int realY = winSize. height + bullet. contentSize .height *0.5;|float ratio = (float) offX / (float) offY; Iint realX = (realY - cannnon .position .y)* ratio + cannnon . position .x; CGPoint realDest = ccp(realX, realY); |/子彈會(huì)于一個(gè)恒定的速率按照射擊方向前進(jìn)
22、int offRealX = realX - cannnon .position .x;int offRealY = realY - cannnon .position .y;float length = sqrtf(offRealX*offRealX)+(offRealY*offRealY);一旦我們有了距離,我們只是除以速度,以獲得所需的時(shí)間。這是因?yàn)樗俣?=距離/時(shí)間,或換句話說(shuō) 時(shí)間=距離/速度。float velocity = 240/1; / 480pixels/1sec |float realMoveDuration = length/velocity;|移除子彈的動(dòng)作CCMov
23、eTo *move = CCMoveTo actionWithDuration :realMoveDuration position :realDest; | CCCallFuncO * removeBullet = CCCallFuncO actionWithTarget :self selector :selector (removeNet:) object:bullet; | CCSequence * bulletSequence = CCSequence actions :move,removeBullet, nil;bullet. rotation = cannnon .rotati
24、on ;bullet runAction :bulletSequence;bulletSheet addChild :bullet; |刪除子彈用于碰撞后及自動(dòng)消失-(void )removeNet:( id)sender |CCLOG(removeNet);CCNet * sp = ( CCNet *)sender; |bulletSheet removeChild :sp cleanup :YES ; 4.魚類精靈的添加(使用紋理圖集批量渲染) 要點(diǎn):設(shè)置魚的的動(dòng)作,魚的隨機(jī)產(chǎn)生-(void) updateFish | while (fishSheet children count max
25、NumberOfFish ) self addFish ;,-(void)addFish |int type = rand ()%9+1;NSMutableArray * oneFish = NSMutableArray array ;int number = 10;for (int i = 1; i (winSize. width + bullet. contentSize .width) | |bullet. position .x (0-bullet. contentSize .width) continue ;CCARRAY_FOREACH (fishSheet children, f
26、ish)if (bullet isHit) continue ;if (CGRectContainsPoint (fish boundingBox , bullet. position ) 子彈碰撞 bullet. isHit = YES;/shownet,remove bullet |/CCLOG(remove bullet);bulletSheet removeChild :bullet cleanup :NO;/CCLOG(remove over); |添加網(wǎng)CCNet * netCatch = CCNet spriteWithSpriteFrameName :NSStringstrin
27、gWithFormat :net0%i.png ,cannonLevel ;netCatch. position = bullet. position ;netSheet addChild :netCatch; |/CCLOG(add net over); |網(wǎng)的動(dòng)作CCCallFuncO * scaleNetAfterShow = CCCallFuncO actionWithTarget :self selector selector (afterShowNet:) object:netCatch; |CCSequence * netSequence = CCSequence |action
28、s :scale0,scale1,scale0,scale1,scaleNetAfterShow, nil;netCatch runAction :netSequence;/CCLOG(add net over); |CCARRAY_FOREACH (netSheet children, net)if (net isHit) continue ;CCARRAY_FOREACH (fishSheet children, fish)if (fish isCatch ) continue ;if (CGRectContainsPoint (net boundingBox , fish. positi
29、on ) if (!(fish randomCatch :cannonLevel ) continue ; elsefish. isCatch = YES;self updateEnergy :fish.fishLevel ;NSMutableArray * fishes = NSMutableArray array; int number; |if (fish. fishLevel 8) number = 3;else number = 5;for (int i = 1; i number; i+) fishes addObject :CCSpriteFrameCache sharedSpr
30、iteFrameCache spriteFrameByName :NSString stringWithFormat :fish0%i_catch_0%i.png ,fish. fishLevel ,i; CCActionInterval * fish_catch_act = CCRepeat actionWithAction :CCAnimateactionWithAnimation :CCAnimation animationWithFrames :fishes delay :0.2f times :2;CCSequence * animalSequence = CCSequence actions :fish_catch_act, CCCallFuncOactionWithTarget :self selector :selector
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 餐飲企業(yè)加盟合同范本:包含品牌使用權(quán)及培訓(xùn)
- 物業(yè)管理公司財(cái)務(wù)外包合同
- 施工方案編制聲明
- 電商代運(yùn)營(yíng)及數(shù)據(jù)分析合作協(xié)議
- 成都市二手房買賣及產(chǎn)權(quán)過(guò)戶稅費(fèi)承擔(dān)及代理服務(wù)合同
- 出租車服務(wù)區(qū)域獨(dú)家經(jīng)營(yíng)權(quán)承包合同
- 神經(jīng)外科帕金森病護(hù)理查房
- 焦化消防應(yīng)急預(yù)案方案
- 油費(fèi)管理方案模板(3篇)
- 2026版《全品高考》選考復(fù)習(xí)方案生物06 實(shí)驗(yàn)十七 探究等溫情況下一定質(zhì)量氣體壓強(qiáng)與體積的關(guān)系含答案
- 2024年中國(guó)沖擊波醫(yī)療器械市場(chǎng)調(diào)查研究報(bào)告
- 小學(xué)英語(yǔ)時(shí)態(tài)練習(xí)大全(附答案)-小學(xué)英語(yǔ)時(shí)態(tài)專項(xiàng)訓(xùn)練及答案
- 新課標(biāo)高一英語(yǔ)閱讀理解60篇
- DB15-T 3585-2024 高標(biāo)準(zhǔn)農(nóng)田施工質(zhì)量評(píng)定規(guī)程
- 2024年新人教版七年級(jí)數(shù)學(xué)下冊(cè)期末考試數(shù)學(xué)試卷-含答案
- 電氣設(shè)備-核電行業(yè)研究框架:成長(zhǎng)性與穩(wěn)定性兼?zhèn)淇春煤穗娭虚L(zhǎng)期價(jià)值
- 杭州浙江杭州市森林和野生動(dòng)物保護(hù)服務(wù)中心招聘編外聘用人員筆試歷年典型考題及考點(diǎn)附答案解析
- 【正版授權(quán)】 ISO 13408-2:2018 EN Aseptic processing of health care products - Part 2: Sterilizing filtration
- 氧氣吸入操作評(píng)分標(biāo)準(zhǔn)(中心供氧)
- 舌系帶短縮治療指南制定與更新
- 傳染病防控新技術(shù)應(yīng)用與評(píng)估
評(píng)論
0/150
提交評(píng)論