问题描述
我的游戏有一个碰撞检测,当我的导弹击中敌人时,敌人就会消失.我想添加一个评分系统,每次我的导弹击中敌人时加 1 分.我将在下面发布我的游戏代码(我使用了 HelloWorldLayer.m)**
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)**
代码如下:
链接 - http://pastebin.com/iGP83SCv
在碰撞部分,我只想让它在每次弹丸击中敌人萌芽"时加 1 分,并在标签中显示分数.示例:得分:0000
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,请尽可能简单地解释一下.
PS, please explain it as easy as possible.
推荐答案
@synthesize
int
类型的 "score" 属性和类型的 "scoreLabel" 属性CCLabelTTF
.
@synthesize
a "score" property of type int
, and a "scoreLabel" property of type CCLabelTTF
.
在 -(void)init
在第 126 行,将score"属性加 1,并将该值设置为 CCLabelTTF
.
On line 126, increment your "score" property by 1, and set that value into your CCLabelTTF
.
这篇关于Cocos2D 中的评分系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!