敌人不会从场景中移除

时间:2016-03-15 16:36:07

标签: ios sprite-kit

当我的子弹触及敌人而不死时我有一个问题我不知道为什么我做错了什么..?

func didBeginContact(contact: SKPhysicsContact) {
    let firstBody: SKPhysicsBody = contact.bodyA
    let secondBody: SKPhysicsBody = contact.bodyB

    if ((firstBody.categoryBitMask == physicsCatagory.Enemy) && (secondBody.categoryBitMask == physicsCatagory.Bullet)) {
        collisionWithBullet(firstBody.node as! SKSpriteNode, bullet: secondBody.node as! SKSpriteNode)
    }
}

func collisionWithBullet(enemy: SKSpriteNode, bullet: SKSpriteNode){
    bullet.removeFromParent()
    enemy.removeFromParent()
}

任何人都知道plz帮助我 ty

0 个答案:

没有答案