捕鱼达人游戏项目开发过程文档.docx

上传人:b****2 文档编号:1760902 上传时间:2023-05-01 格式:DOCX 页数:15 大小:90.80KB
下载 相关 举报
捕鱼达人游戏项目开发过程文档.docx_第1页
第1页 / 共15页
捕鱼达人游戏项目开发过程文档.docx_第2页
第2页 / 共15页
捕鱼达人游戏项目开发过程文档.docx_第3页
第3页 / 共15页
捕鱼达人游戏项目开发过程文档.docx_第4页
第4页 / 共15页
捕鱼达人游戏项目开发过程文档.docx_第5页
第5页 / 共15页
捕鱼达人游戏项目开发过程文档.docx_第6页
第6页 / 共15页
捕鱼达人游戏项目开发过程文档.docx_第7页
第7页 / 共15页
捕鱼达人游戏项目开发过程文档.docx_第8页
第8页 / 共15页
捕鱼达人游戏项目开发过程文档.docx_第9页
第9页 / 共15页
捕鱼达人游戏项目开发过程文档.docx_第10页
第10页 / 共15页
捕鱼达人游戏项目开发过程文档.docx_第11页
第11页 / 共15页
捕鱼达人游戏项目开发过程文档.docx_第12页
第12页 / 共15页
捕鱼达人游戏项目开发过程文档.docx_第13页
第13页 / 共15页
捕鱼达人游戏项目开发过程文档.docx_第14页
第14页 / 共15页
捕鱼达人游戏项目开发过程文档.docx_第15页
第15页 / 共15页
亲,该文档总共15页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

捕鱼达人游戏项目开发过程文档.docx

《捕鱼达人游戏项目开发过程文档.docx》由会员分享,可在线阅读,更多相关《捕鱼达人游戏项目开发过程文档.docx(15页珍藏版)》请在冰点文库上搜索。

捕鱼达人游戏项目开发过程文档.docx

捕鱼达人游戏项目开发过程文档

捕鱼达人游戏项目开发过程文档

捕鱼达人项目开发过程文档

一、游戏资源文件

image图片:

包括火炮,鱼,子弹,渔网,金币,数字,背景图片以及其它UI图片

CCFish类:

实现鱼的曲线路线的移动与各种鱼捕捉概率的设置

UINumber类与UIRollNumber类

二、游戏基本结构确定及搭建

图1.1

依次在项目中创建如有图类

完成项目结构,在总体上把握项目实现内容

三、详细设计与各功能模块的实现

程序编写流程

1.系统菜单场景:

1)添加初始化方法

2)添加菜单

selector:

@selector(reduceCannonLeave)];

CCMenu*reduceMenu=[CCMenumenuWithItems:

reduceItem,nil];

reduceMenu.position=ccp(winSize.width*0.5-30,10);

[reduceMenualignItemsVertically];

[selfaddChild:

reduceMenuz:

102];

//初始化金币数

gold=[[UIRollNumberalloc]init];

[goldsetNumber:

originGold];

[goldsetPosition:

ccp(168,10)];

[selfaddChild:

goldz:

102];

}

-(void)addCannonLeave

{

CGSizewinSize=[[CCDirectorsharedDirector]winSize];

cannonLevel++;

If(cannonLevel==8)

cannonLevel=1;

//removecannon

CCScaleTo*narrow=[CCScaleToactionWithDuration:

0.1fscale:

0.1];

CCCallFuncO*removeCannon=[CCCallFuncOactionWithTarget:

selfselector:

@selector(removeCannon:

)object:

cannnon];

CCSequence*bowDismissSequence=[CCSequenceactions:

narrow,removeCannon,nil];

[cannnonrunAction:

bowDismissSequence];

//addanewcannon

cannnon=[CCCannonspriteWithSpriteFrameName:

[NSStringstringWithFormat:

@"actor_cannon1_%i1.png",cannonLevel]];

cannnon.cannonLevel=cannonLevel;

cannnon.position=ccp(winSize.width*0.5,30);

cannnon.scale=0.1f;

CCDelayTime*delayTime=[CCDelayTimeactionWithDuration:

0.1f];

CCScaleTo*appear=[CCScaleToactionWithDuration:

0.1fscale:

cannon_scale];

CCSequence*bowAppearSequence=[CCSequenceactions:

delayTime,appear,nil];

[cannnonrunAction:

bowAppearSequence];

[cannonSheetaddChild:

cannnonz:

100];

}

//删除武器用于武器改变

-(void)removeCannon:

(id)sender

{

//CCLOG(@"removeBow");

CCCannon*sp=sender;

[cannonSheetremoveChild:

spcleanup:

YES];

}

1.触摸事件模块

要点:

子弹、大炮的跟随转向,子弹射出速度设置,越界判定(移动出画面)

-(void)setAngle:

(CGPoint)pointsprite:

(CCSprite*)sp

{

//CCLOG(@"setAngle");

//设置“旋转角度”

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);//设置武器旋转角度

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){//如果当前为超级武器,

}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)

{

//用超级能量捕捉动物(待改)

cannnon.cannonType=nomal;//发射完毕还原武器

}

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);

//子弹会于一个恒定的速率按照射击方向前进

intoffRealX=realX-cannnon.position.x;

intoffRealY=realY-cannnon.position.y;

floatlength=sqrtf((offRealX*offRealX)+(offRealY*offRealY));

//一旦我们有了距离,我们只是除以速度,以获得所需的时间。

这是因为速度=距离/时间,或换句话说时间=距离/速度。

floatvelocity=240/1;//480pixels/1sec

floatrealMoveDuration=length/velocity;

//移除子弹的动作

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];

}

}

}

//删除子弹用于碰撞后及自动消失

-(void)removeNet:

(id)sender

{

//CCLOG(@"removeNet");

CCNet*sp=(CCNet*)sender;

[bulletSheetremoveChild:

spcleanup:

YES];

}

2.鱼类精灵的添加(使用纹理图集批量渲染)

要点:

设置鱼的的动作,鱼的随机产生

-(void)updateFish

{

while([[fishSheetchildren]count]

[selfaddFish];

}

}

-(void)addFish

{

inttype=rand()%9+1;

NSMutableArray*oneFish=[NSMutableArrayarray];

intnumber=10;

for(inti=1;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;//默认为未被抓

[fishrunAction:

fishAction];

[fishaddPath];//添加路线

[fishrun];

[fishSheetaddChild:

fishz:

100];

}

3.碰撞检测的处理

要点:

渔网与鱼,子弹和鱼的检测方式(点面触碰与面面触碰区别),鱼,网,子弹见逻辑关系(碰撞标志的设置),

-(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");

//添加网

CCNet*netCatch=[CCNetspriteWithSpriteFrameName:

[NSStringstringWithFormat:

@"net0%i.png",cannonLevel]];

netCatch.position=bullet.position;

[netSheetaddChild:

netCatch];

//CCLOG(@"addnetover");

//网的动作

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

[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],nil];

[fishstopAllActions];

[fishrunAction:

animalSequence];

//得分显示动作(间隔0.5s)

CCCallFuncO*scoreShow=[CCCallFuncOactionWithTarget:

selfselector:

@selector(goldShow:

)object:

gold];

CCSequence*scoreSequence=[CCSequenceactions:

[CCActionIntervalactionWithDuration:

0.5],scoreShow,nil];

[goldrunAction:

scoreSequence];

}

}

}

net.isHit=YES;

}

}

4.其它润色

1)能量槽的设置---转动起来

-(void)updateEnergy:

(int)addEnergy

{

//CCLOG(@"updateEnergy");

energy+=addEnergy;

energyPointer.rotation=((float)energy/maxEnergy)*(maxEnergyRotation-minEnergyRotation)+minEnergyRotation;

}

2)音乐与音效----游戏背景音乐

SimpleAudioEngine文件的具体使用,包括背景音乐及音效的控制,开始,暂停,停止等使用语句如下:

[[SimpleAudioEngine sharedEngine]playBackgroundMusic:

@"background-music-aac.caf"];

[[SimpleAudioEngine sharedEngine] playEffect:

@"pew-pew-lei.caf"];

3)更多的场景----场景更迭(巧妙使用更新方法)

在更新方法的使用中已经提到,可以通过预定信息的开始结束等操作,使得游戏按照我们的剧本进行,场景的更迭便是一个很好的应用,有兴趣的同学可以试着实现一下,包括背景图层的改变与切换效果,鱼巡游队列的设计与实现在此我只做几个简单的提示

1.封装在鱼类中的游动路线CCSpeed可以改变游动速度

2.巧妙使用动作序列CCSequence以及更新方法以达到“剧本”效果

3.法无定法,先实现再优化

4)道具的实现------做自己的游戏

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 总结汇报 > 学习总结

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2