Cocos2D:塔防游戏制作之旅(十八)
在Enemy.m的getDamaged:方法只给你添加如下1行(在if条件内): [theGame awardGold:200];
现在运行游戏你将注意到你不能放置超出你资源金币的炮塔了.当然杀死敌人可以奖励金币,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!)!这里有太多你可以改进的地方,这里仅仅是几个主意:
(Cocos2D:塔防游戏制作之旅全篇完) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |