0
votes

I'm new to sprite kit and I'm trying to finalize my last bit of code. I'm trying to see if the there are any more certain types of nodes on the screen before I leave the game scene. noMoreOrangesFlag is a private variable I put on the top of the swift file. Please let me know how I can accomplish this.

var noMoreOrangesFlag = false;

/**
 * @Name: didEvaluateActions
 * @Description: This is part of the lifecycle of the app per frame.
 * @Parameters: None
 * @Returns: void
 * @Throws: No Excception
 */

override func didEvaluateActions() {
    if(gameOverFlag){
        // This is a private variable I need to change
        noMoreOrangesFlag = false;

        // This is where I'm trying to see if there are any oranges on the screen
        enumerateChildNodesWithName(orangeImageName) { node, _ in
            self.noMoreOrangesFlag = true;
        }

        if(!noMoreOrangesFlag){
            // THIS IS THE FINAL THING RAN. OFFICIAL GAME OVER

            NSLog("Machine");
        }
    }
}
1

1 Answers

0
votes

Using the method accomplishes what I want

if(childNodeWithName(orangeImageName) == nil){
                // THIS IS THE FINAL THING RAN. OFFICIAL GAME OVER

                NSLog("Machine");
}