计分系统在Cocos2D [英] Scoring System In Cocos2D
问题描述
我的游戏有一个碰撞检测,当我的导弹击中敌人敌人消失。我想添加一个计分系统,每当我的导弹击中敌人时加1分。我将在下面发布我的游戏代码(我使用HelloWorldLayer.m)**
这里是代码:
链接 - http://pastebin.com/iGP83SCv
在碰撞部分,我只想要每当弹丸击中敌人发芽时添加1分,并在标签中显示分数。示例:分数:0000
PS,请尽可能简单解释。
@synthesize
类型 int
的score属性,以及类型的scoreLabel属性 - (void)初始化您的score属性为0( CCLabelTTF
。
<
$ b 在第126行,将score属性增加1,并将该值设置为 CCLabelTTF 。
My game has a collision detection where when my missile hits the enemy the enemy disappears. I want to add a scoring system that adds 1 point every time my missile hits the enemy. I'll post my game code below (I used the HelloWorldLayer.m)**
Here is the code:
Link - http://pastebin.com/iGP83SCv
In the collision section i just want it to add 1 point every time the projectile hits the enemy "sprout" and display the score in label. Example: Score:0000
PS, please explain it as easy as possible.
解决方案 @synthesize
a "score" property of type int
, and a "scoreLabel" property of type CCLabelTTF
.
initialize your score property to "0" in -(void)init
On line 126, increment your "score" property by 1, and set that value into your CCLabelTTF
.
这篇关于计分系统在Cocos2D的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!