文档介绍:项目总结
我们的项目是初级版的植物大战僵尸,植物大战僵尸是一款极富策略性的小游戏,游戏的规则是:玩家控制植物,抵御僵尸的进攻,保护这片草坪防止僵尸进入房间。
在这个项目开发过程中,通过小组讨论,我们确定了该项目的基本功能,包括产生僵尸、消灭僵尸、游戏失败时的提示、计数以及音效等方面的内容,其中和僵尸有关的是加载僵尸、僵尸的移动和消除。
开发过程中,我们使用了试图控制器以及视图来实现界面,学会了关联控件、为可变数组添加新元素,了解并能使用UILabel、UIImageView、UIViewController等基本UI控件实例化出僵尸,能实现僵尸的移动。
(1)游戏视图
(2)信息提示
-(void)zoomMove
{
for (ZoomImageView *zoomImage in zoomArray)
{
[zoomImage move];
//[self zoomMiss:zoomImage];
NSLog(@"zoomImage move:%f",);
if ( < -20) {
int zoomx=x[arc4random()%6];
int zoomy=y[arc4random()%6];
=CGPointMake(zoomx,zoomy);
homecount++;
[ setText:[NSString stringWithFormat:@"%d",homecount]];
if(homecount==10)
{
isLose = YES;
[zoomTimer invalidate];
UIImageView *imageview=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
[imageview setImage:[UIImage imageNamed:@""]];
= 100;
[ addSubview:imageview];
NSString *file=[[NSBundle mainBundle] pathForResource:@"lose" ofType:@".mp3"];
NSURL *url=[NSURL fileURLWithPath:file];
AVAudioPlayer *player=[[AVAudioPlayer alloc]initWithContentsOfURL:url error:nil];
[player play];
UIAlertView *zoomAlertView=[[UIAlertView alloc]initWithTitle:@"Game Over"message:@"失败!" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];