您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 项目/工程管理 > 捕鱼达人游戏项目开发过程文档
捕鱼达人项目开发过程文档一、游戏资源文件image图片:包括火炮,鱼,子弹,渔网,金币,数字,背景图片以及其它UI图片CCFish类:实现鱼的曲线路线的移动与各种鱼捕捉概率的设置UINumber类与UIRollNumber类二、游戏基本结构确定及搭建图1.1依次在项目中创建如有图类完成项目结构,在总体上把握项目实现内容三、详细设计与各功能模块的实现程序编写流程1.系统菜单场景:1)添加初始化方法2)添加菜单3)添加菜单选项方法2.游戏场景1)添加初始化方法2)添加纹理图集载入方法3)添加UI设计方法4)添加触摸事件处理方法5)添加自动补充鱼更新方法6)添加碰撞检测方法3.设置页面4.帮助场景游戏重要模块详细实现1.纹理图集的使用与加载要点:精灵处于界面中的层次关系,如下为纹理图集加载代码[[CCSpriteFrameCachesharedSpriteFrameCache]addSpriteFramesWithFile:@fish.plist];fishSheet=[CCSpriteBatchNodebatchNodeWithFile:@fish.png];[selfaddChild:fishSheetz:100];2.UI设计的细节实现要点:各个UI部件(精灵)的层次,位置调整以及武器的更换动作设置,下面为UI实现代码-(void)initUI{SysMenu(scene)GameMain(scene)Setting(layer)Help(scene)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];[selfaddChild:addMenuz:102];CCMenuItem*reduceItem=[CCMenuItemFontitemFromString:@-target:selfselector:@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;//removecannonCCScaleTo*narrow=[CCScaleToactionWithDuration:0.1fscale:0.1];CCCallFuncO*removeCannon=[CCCallFuncOactionWithTarget:selfselector:@selector(removeCannon:)object:cannnon];CCSequence*bowDismissSequence=[CCSequenceactions:narrow,removeCannon,nil];[cannnonrunAction:bowDismissSequence];//addanewcannoncannnon=[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];}3.触摸事件模块要点:子弹、大炮的跟随转向,子弹射出速度设置,越界判定(移动出画面)-(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(angle0){cannnon.rotation=-(90+angle);//设置武器旋转角度sp.rotation=cannnon.rotation;}elseif(angle0){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
本文标题:捕鱼达人游戏项目开发过程文档
链接地址:https://www.777doc.com/doc-5376673 .html