zl程序教程

您现在的位置是:首页 >  其他

当前栏目

Cocos2D:塔防游戏制作之旅(十八)

游戏 之旅 制作 cocos2d 十八
2023-09-14 08:56:50 时间

现在运行游戏你将注意到你不能放置超出你资源金币的炮塔了.当然杀死敌人可以奖励金币,so你可以继续购买更多的炮塔!这是一个令人惊叹的系统,不是吗?

这里写图片描述

现在,最终,对于一些额外的地方,添加一些酷酷的背景音乐(由Kevin MacLeod制作)和cxfr制作的音效,他们可以使你的游戏更有趣一些!

打开HelloWorldLayer.m并且添加以下修改:

//At the top of the file:

#import "SimpleAudioEngine.h"

//Inside init: (inside the "if" condition)

// 9 - sound

[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"8bitDungeonLevel.mp3" loop:YES];

//Inside ccTouchesBegan, before instantiating a new Tower object:

[[SimpleAudioEngine sharedEngine] playEffect:@"tower_place.wav"];

//At the beginning of getHpDamage

[[SimpleAudioEngine sharedEngine] playEffect:@"life_lose.wav"];

现在打开Enemy.m并且添加如下几行:

//At the top of the file:

#import "SimpleAudioEngine.h"

//At the beginning of getDamaged:

[[SimpleAudioEngine sharedEngine] playEffect:@"laser_shoot.wav"];

到这为止了 - 你已经完完全全的完成了!编译运行游戏把玩它吧.你难道不喜欢这些流行的声音吗?

接下来该做神马呢?

这里是 sample project 包含上面塔防游戏之旅全部代码的项目.

如果你想要继续改造该项目,脑洞大开没有上限(the sky’s the limit!)!这里有太多你可以改进的地方,这里仅仅是几个主意: