捕魚達人游戲項目開發(fā)過程文檔_第1頁
捕魚達人游戲項目開發(fā)過程文檔_第2頁
捕魚達人游戲項目開發(fā)過程文檔_第3頁
捕魚達人游戲項目開發(fā)過程文檔_第4頁
捕魚達人游戲項目開發(fā)過程文檔_第5頁
已閱讀5頁,還剩4頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

1、捕魚達人項目開發(fā)過程文檔一、游戲資源文件UI圖片image圖片:包括火炮,魚,子彈,漁網(wǎng),金幣,數(shù)字,背景圖片以及其它CCFish類:實現(xiàn)魚的曲線路線的移動與各種魚捕捉概率的設置UINumber 類與 UIRollNumber 類二、游戲基本結(jié)構(gòu)確定及搭建SysMenu(scene)GameMain(scene)Setting(layer)Help(scene)圖1.1依次在項目中創(chuàng)建如有圖類完成項目結(jié)構(gòu),在總體上把握項目實現(xiàn)內(nèi)容、詳細設計與各功能模塊的實現(xiàn)程序編寫流程1.系統(tǒng)菜單場景:1)2)3)添加初始化方法添加菜單添加菜單選項方法2.游戲場景1)2)3)4)5)6)添加初始化方法添加紋理

2、圖集載入方法添加UI設計方法添加觸摸事件處理方法 添加自動補充魚更新方法 添加碰撞檢測方法二 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.設置頁面幫助場景游戲重要模塊詳細實現(xiàn)1 .紋理圖集的使用與加載要點:精靈處于界面中的層次關系,如下為紋理圖集加載代碼CCSpriteFrameCache sharedSpriteFrameCache addSpriteFramesWithFile :fish.plist;fishSheet = CCSpriteBatchNode batchNodeWithFile :fish.png;self addChild :fishSheet z:1

4、00;2 . UI設計的細節(jié)實現(xiàn)要點:各個 UI部件(精靈)的層次,位置調(diào)整以及武器的更換動作設置,下面為UI實現(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.觸摸事件模塊要點:子彈、大炮的跟隨轉(zhuǎn)向,子彈射出速度設置,越界判定(移動出畫面)- (void) setAngle:( CG

15、Point )point sprite:( CCSprite *)sp /CCLOG(setAngle); |/設置旋轉(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) 如果當前為超級武器, 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)用超級能量捕捉動物(待改)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); |/子彈會于一個恒定的速率按照射擊方向前進

22、int offRealX = realX - cannnon .position .x;int offRealY = realY - cannnon .position .y;float length = sqrtf(offRealX*offRealX)+(offRealY*offRealY);一旦我們有了距離,我們只是除以速度,以獲得所需的時間。這是因為速度 =距離/時間,或換句話說 時間=距離/速度。float velocity = 240/1; / 480pixels/1sec |float realMoveDuration = length/velocity;|移除子彈的動作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; |刪除子彈用于碰撞后及自動消失-(void )removeNet:( id)sender |CCLOG(removeNet);CCNet * sp = ( CCNet *)sender; |bulletSheet removeChild :sp cleanup :YES ; 4.魚類精靈的添加(使用紋理圖集批量渲染) 要點:設置魚的的動作,魚的隨機產(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)的動作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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論