精灵套装得分随机增加

时间:2018-03-25 18:21:40

标签: ios iphone swift sprite-kit

当玩家联系硬币时,分数随机增加,我希望它增加1

 func didBegin(_ contact: SKPhysicsContact) {

    let firsBody = contact.bodyA
    let secondBody = contact.bodyB

    if firsBody.categoryBitMask == scoreCatagory && secondBody.categoryBitMask == playerCatagory || firsBody.categoryBitMask == playerCatagory && secondBody.categoryBitMask == scoreCatagory   {

        score = score + 1
        scoreLable.text = "\(score)"



    }

0 个答案:

没有答案