Scoring System In Cocos2D(Cocos2D 中的评分系统)
问题描述
我的游戏有一个碰撞检测,当我的导弹击中敌人时,敌人就会消失.我想添加一个评分系统,每次我的导弹击中敌人时加 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 中的评分系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Cocos2D 中的评分系统


基础教程推荐
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01