捕魚(yú)達(dá)人游戲項(xiàng)目開(kāi)發(fā)過(guò)程文檔_第1頁(yè)
捕魚(yú)達(dá)人游戲項(xiàng)目開(kāi)發(fā)過(guò)程文檔_第2頁(yè)
捕魚(yú)達(dá)人游戲項(xiàng)目開(kāi)發(fā)過(guò)程文檔_第3頁(yè)
捕魚(yú)達(dá)人游戲項(xiàng)目開(kāi)發(fā)過(guò)程文檔_第4頁(yè)
捕魚(yú)達(dá)人游戲項(xiàng)目開(kāi)發(fā)過(guò)程文檔_第5頁(yè)
已閱讀5頁(yè),還剩4頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

捕魚(yú)達(dá)人項(xiàng)目開(kāi)發(fā)過(guò)程文檔游戲資源文件image圖片:包括火炮,魚(yú),子彈,漁網(wǎng),金幣,數(shù)字,背景圖片以及其它UI圖片CCFish類:實(shí)現(xiàn)魚(yú)的曲線路線的移動(dòng)與各種魚(yú)捕捉概率的設(shè)置UINumber類與UIRollNumber類游戲基本結(jié)構(gòu)確定及搭建SysMenuSysMenu(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)程序編寫(xiě)流程系統(tǒng)菜單場(chǎng)景:添加初始化方法添加菜單添加菜單選項(xiàng)方法游戲場(chǎng)景添加初始化方法添加紋理圖集載入方法添加UI設(shè)計(jì)方法添加觸摸事件處理方法添加自動(dòng)補(bǔ)充魚(yú)更新方法添加碰撞檢測(cè)方法設(shè)置頁(yè)面幫助場(chǎng)景 游戲重要模塊詳細(xì)實(shí)現(xiàn)紋理圖集的使用與加載要點(diǎn):精靈處于界面中的層次關(guān)系,如下為紋理圖集加載代碼[[CCSpriteFrameCachesharedSpriteFrameCache]addSpriteFramesWithFile:@"fish.plist"];fishSheet=[CCSpriteBatchNodebatchNodeWithFile:@"fish.png"];[selfaddChild:fishSheetz:100];UI設(shè)計(jì)的細(xì)節(jié)實(shí)現(xiàn)要點(diǎn):各個(gè)UI部件(精靈)的層次,位置調(diào)整以及武器的更換動(dòng)作設(shè)置,下面為UI實(shí)現(xiàn)代碼 -(void)initUI { CGSizewinSize=[[CCDirectorsharedDirector]winSize]; CCSprite*background=[CCSpritespriteWithFile:@"bj00.jpg"]; background.position=ccp(winSize.width*0.5,winSize.height*0.5); [selfaddChild:backgroundz:0]; //添加能量槽 CCSprite*engryBox=[CCSpritespriteWithFile:@"ui_2p_004.png"]; engryBox.anchorPoint=ccp(0.5,0.5); engryBox.position=ccp(winSize.width/2,10); [selfaddChild:engryBoxz:10]; //添加能量箭頭 energyPointer=[CCSpritespriteWithFile:@"ui_2p_005.png"]; energyPointer.anchorPoint=ccp(0.5,0.5); energyPointer.position=ccp(winSize.width/2,10); energyPointer.rotation=minEnergyRotation; [selfaddChild:energyPointerz:12]; //添加頂部框體 CCSprite*bgExp=[CCSpritespriteWithFile:@"ui_box_01.png"]; bgExp.position=ccp(winSize.width/2,winSize.height); bgExp.anchorPoint=ccp(0.5f,1.0f); [selfaddChild:bgExpz:101]; //添加底框 CCSprite*bgNum=[CCSpritespriteWithFile:@"ui_box_02.png"]; bgNum.position=ccp(bgNum.contentSize.width/2,0); bgNum.anchorPoint=ccp(0.5f,0); [selfaddChild:bgNumz:101]; //添加武器cannnon=[CCCannonspriteWithSpriteFrameName:[NSStringstringWithFormat:@"actor_cannon1_%i1.png",1]]; cannnon.cannonLevel=1; cannonLevel=1; cannnon.anchorPoint=ccp(0.5f,0.5f); cannnon.position=ccp(winSize.width/2,30); cannnon.scale=cannon_scale; cannnon.cannonType=nomal; [cannonSheetaddChild:cannnon]; //添加“+”,“-”按鈕(待改) [CCMenuItemFontsetFontSize:32]; [CCMenuItemFontsetFontName:@"Arial"]; CCMenuItem*addItem=[CCMenuItemFontitemFromString:@"+"target:selfelector:@selector(addCannonLeave)]; //addItem.scale=1.5; CCMenu*addMenu=[CCMenumenuWithItems:addItem,nil]; addMenu.position=ccp(winSize.width*0.5+30,10); [addMenualignItemsVertically]; }觸摸事件模塊要點(diǎn):子彈、大炮的跟隨轉(zhuǎn)向,子彈射出速度設(shè)置,越界判定(移動(dòng)出畫(huà)面) -(void)setAngle:(CGPoint)pointsprite:(CCSprite*)sp { //CCLOG(@"setAngle"); //設(shè)置“旋轉(zhuǎn)角度” intoffX=point.x-cannnon.position.x; intoffY=point.y-cannnon.position.y; if(offY<=0){ return; } floatratio=(float)offY/(float)offX; //直角三角形 floatangle=atanf(ratio)/M_PI*180; //三角形正切值獲得角度 if(angle<0){ cannnon.rotation=-(90+angle); //設(shè)置武器旋轉(zhuǎn)角度 sp.rotation=cannnon.rotation; }elseif(angle>0){ cannnon.rotation=90-angle; sp.rotation=cannnon.rotation; } } #pragmatouchmenthed -(void)ccTouchesBegan:(NSSet*)toucheswithEvent:(UIEvent*)event { for(UITouch*touchintouches) { CGPointpos=[touchlocationInView:touch.view]; pos=[[CCDirectorsharedDirector]convertToGL:pos]; if(pos.y<=cannnon.position.y){ return; } if(cannnon.cannonType==laser){ //如果當(dāng)前為超級(jí)武器, }else{ [cannnonsetDisplayFrame:[[CCSpriteFrameCachesharedSpriteFrameCache]spriteFrameByName:[NSStringstringWithFormat:@"actor_cannon1_%i2.png",cannnon.cannonLevel]]]; } [selfsetAngle:possprite:nil]; } } -(void)ccTouchesMoved:(NSSet*)toucheswithEvent:(UIEvent*)event { for(UITouch*touchintouches){ CGPointpos=[touchlocationInView:touch.view]; pos=[[CCDirectorsharedDirector]convertToGL:pos]; [selfsetAngle:possprite:nil]; } } -(void)ccTouchesEnded:(NSSet*)toucheswithEvent:(UIEvent*)event { for(UITouch*touchintouches) { CGSizewinSize=[[CCDirectorsharedDirector]winSize]; CGPointpos=[touchlocationInView:touch.view]; pos=[[CCDirectorsharedDirector]convertToGL:pos]; intoffX=pos.x-cannnon.position.x; intoffY=pos.y-cannnon.position.y; if(offY<=0){ return; } if(cannnon.cannonType==laser) { //用超級(jí)能量捕捉動(dòng)物(待改) cannnon.cannonType=nomal; //發(fā)射完畢還原武器 } else { //***************(待改)******************* [goldsetNumber:([goldgetNumber]-cannnon.cannonType)];//每次損耗CCBullet*bullet=[CCBulletspriteWithSpriteFrameName:[NSStringstringWithFormat:@"bullet0%i.png",cannnon.cannonLevel]]; //添加子彈 bullet.position=cannnon.position; bullet.isHit=NO; [selfsetAngle:possprite:bullet]; //Determinewherewewishtoshoottheprojectileto intrealY=winSize.height+bullet.contentSize.height*0.5; floatratio=(float)offX/(float)offY; intrealX=(realY-cannnon.position.y)*ratio+cannnon.position.x; CGPointrealDest=ccp(realX,realY); //子彈會(huì)于一個(gè)恒定的速率按照射擊方向前進(jìn) intoffRealX=realX-cannnon.position.x; intoffRealY=realY-cannnon.position.y; floatlength=sqrtf((offRealX*offRealX)+(offRealY*offRealY)); //一旦我們有了距離,我們只是除以速度,以獲得所需的時(shí)間。這是因?yàn)樗俣?距離/時(shí)間,或換句話說(shuō)時(shí)間=距離/速度。 floatvelocity=240/1;//480pixels/1sec floatrealMoveDuration=length/velocity; //移除子彈的動(dòng)作 CCMoveTo*move=[CCMoveToactionWithDuration:realMoveDurationposition:realDest];CCCallFuncO*removeBullet=[CCCallFuncOactionWithTarget:selfselector:@selector(removeNet:)object:bullet]; CCSequence*bulletSequence=[CCSequenceactions:move,removeBullet,nil]; bullet.rotation=cannnon.rotation; [bulletrunAction:bulletSequence]; [bulletSheetaddChild:bullet]; } } } //刪除子彈用于碰撞后及自動(dòng)消失 -(void)removeNet:(id)sender { //CCLOG(@"removeNet"); CCNet*sp=(CCNet*)sender; [bulletSheetremoveChild:spcleanup:YES]; }魚(yú)類精靈的添加(使用紋理圖集批量渲染)要點(diǎn):設(shè)置魚(yú)的的動(dòng)作,魚(yú)的隨機(jī)產(chǎn)生-(void)updateFish{while([[fishSheetchildren]count]<maxNumberOfFish){[selfaddFish];}}-(void)addFish{ inttype=rand()%9+1; NSMutableArray*oneFish=[NSMutableArrayarray];intnumber=10; for(inti=1;i<number;i++) { [oneFishaddObject:[[CCSpriteFrameCachesharedSpriteFrameCache] spriteFrameByName:[NSStringstringWithFormat:@"fish0%i_0%i.png",type,i]]]; } CCRepeat*fishAction=[CCRepeatForeveractionWithAction:[CCAnimateactionWithAnimation:[CCAnimationanimationWithFrames:oneFishdelay:0.2f]restoreOriginalFrame:YES]];CCFish*fish=[CCFishspriteWithSpriteFrameName:[NSStringstringWithFormat:@"fish0%i_0%i.png",type,1]];fish.scale=0.6f;fish.fishLevel=type;fish.isCatch=NO;//默認(rèn)為未被抓[fishrunAction:fishAction];[fishaddPath]; //添加路線 [fishrun];[fishSheetaddChild:fishz:100];}碰撞檢測(cè)的處理要點(diǎn):漁網(wǎng)與魚(yú),子彈和魚(yú)的檢測(cè)方式(點(diǎn)面觸碰與面面觸碰區(qū)別),魚(yú),網(wǎng),子彈見(jiàn)邏輯關(guān)系(碰撞標(biāo)志的設(shè)置),-(void)updateHit{CGSizewinSize=[[CCDirectorsharedDirector]winSize];CCFish*fish;CCNet*net;CCBullet*bullet;CCScaleTo*scale0=[CCScaleToactionWithDuration:0.3scale:1.1];CCScaleTo*scale1=[CCScaleToactionWithDuration:0.3scale:0.8];CCARRAY_FOREACH([bulletSheetchildren],bullet)//遍歷子彈{if([bulletisHit]){continue;}if(bullet.position.x>(winSize.width+bullet.contentSize.width)||bullet.position.x<(0-bullet.contentSize.width)){continue;}CCARRAY_FOREACH([fishSheetchildren],fish){if([bulletisHit]){continue;}if(CGRectContainsPoint([fishboundingBox],bullet.position)){//子彈碰撞bullet.isHit=YES;//shownet,removebullet//CCLOG(@"removebullet");[bulletSheetremoveChild:bulletcleanup:NO];//CCLOG(@"removeover");//添加網(wǎng)CCNet*netCatch=[CCNetspriteWithSpriteFrameName:[NSStringstringWithFormat:@"net0%i.png",cannonLevel]];netCatch.position=bullet.position;[netSheetaddChild:netCatch];//CCLOG(@"addnetover");//網(wǎng)的動(dòng)作CCCallFuncO*scaleNetAfterShow=[CCCallFuncOactionWithTarget:selfselector:@selector(afterShowNet:)object:netCatch];CCSequence*netSequence=[CCSequenceactions:scale0,scale1,scale0,scale1,scaleNetAfterShow,nil];[netCatchrunAction:netSequence];//CCLOG(@"addnetover");}}}CCARRAY_FOREACH([netSheetchildren],net){if([netisHit]){continue;}CCARRAY_FOREACH([fishSheetchildren],fish){if([fishisCatch]){continue;}if(CGRectContainsPoint([netboundingBox],fish.position)){if(!([fishrandomCatch:cannonLevel])){continue;}else{fish.isCatch=YES;[selfupdateEnergy:fish.fishLevel];NSMutableArray*fishes=[NSMutableArrayarray];intnumber;if(fish.fishLevel<8){number=3;}else{number=5;}for(inti=1;i<number;i++){[fishesaddObject:[[CCSpriteFrameCachesharedSpriteFrameCache]spriteFrameByName:[NSStringstringWithFormat:@"fish0%i_catch_0%i.png",fish.fishLevel,i]]];}CCActionInterval*fish_catch_act=[CCRepeatactionWithAction:[CCAnimateactionWithAnimation:[CCAnimationanimationWithFrames:fishesdelay:0.2f]]times:2];CCSequence*animalSequence=[CCSequenceactions:fish_catch_act,[CCCallFuncOactionWithTarget:selfselector:@selector(afterCatch:)object:fish],n

溫馨提示

  • 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ì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論