I have come upon a road block in designing my game. In this game, a brick falls from the top of the screen down, moving towards and square with different sides. If the brick matches up with the holes in side of the square, then it would be "correct". Regarding game logic, any suggestions of what code to write/change in order to print "correct."
extension GameScene: SKPhysicsContactDelegate {
func didBegin(_ contact: SKPhysicsContact) {
let contactMask = contact.bodyA.categoryBitMask |
contact.bodyB.categoryBitMask
if contactMask == PhysicsCategories.brickCategory |
PhysicsCategories.basicBrickCategory {
if let brick = contact.bodyA.node?.name == "Brick" ?
contact.bodyA.node as? SKSpriteNode : contact.bodyB.node as?
SKSpriteNode {
if {
print("Correct")
brick.run(SKAction.fadeOut(withDuration: 0.5), completion: {
brick.removeFromParent()
self.spawnBrick()
})
} else {
gameOver()
}
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire