与对象碰撞时增加整数。迅速

时间:2015-08-30 17:58:11

标签: ios xcode swift

我有一些代码可以为我的游戏创建和打印分数,但我希望分数在与另一个对象发生碰撞时增加。尽管我付出了最大的努力,但我还是看不出如何做到这一点。

这是处理分数的代码:

import SpriteKit

public class Score {
    public let Label = SKLabelNode(fontNamed: "Chalkduster")

    private var currentScore = 0

    public func Setup (fontSize: CGFloat, x: CGFloat, y: CGFloat) {
        Label.fontSize = fontSize
        Label.position.x = x
        Label.position.y = y
        SetScore(currentScore)
    }

    public func SetScore(value: Int) {
        currentScore = value
        Label.text = String(currentScore)
    }

    public func IncrementScore(value: Int) {
        SetScore(currentScore + value)
    }
}

0 个答案:

没有答案