     var sequencePosition = 0
     var chainDelay = 3.0
     var nextSequenceQueued = true
+    var gameEnded = false
     
     override func didMoveToView(view: SKView) {
         /* Setup your scene here */

        redrawActiveSlice()
        
        playSwooshSound()
    }
    
    override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {

            runAction(swooshSound) { [unowned self] in
                self.swooshSoundActive = false
            }
        }
    }
    
    func subtractLife() {
        lives -= 1
        
        runAction(SKAction.playSoundFileNamed("wrong.caf", waitForCompletion: false))
        
        var life: SKSpriteNode
        
        if lives == 2 {
            life = livesImages[0]
        } else if lives == 1 {
            life = livesImages[1]
        } else {
            life = livesImages[2]
            endGame(triggeredByBomb: false)
        }
        
        life.texture = SKTexture(imageNamed: "sliceLifeGone")
        
        life.xScale = 1.3
        life.yScale = 1.3
        life.runAction(SKAction.scaleTo(1, duration:0.1))
    }
    
    func endGame(triggeredByBomb triggeredByBomb: Bool) {
        if gameEnded {
            return
        }
        
        gameEnded = true
        physicsWorld.speed = 0
        userInteractionEnabled = false
        
        if bombSoundEffect != nil {
            bombSoundEffect.stop()
            bombSoundEffect = nil
        }
        
        if triggeredByBomb {
            livesImages[0].texture = SKTexture(imageNamed: "sliceLifeGone")
            livesImages[1].texture = SKTexture(imageNamed: "sliceLifeGone")
            livesImages[2].texture = SKTexture(imageNamed: "sliceLifeGone")
        }
    }
    
