Attempting to create a customisable background button in XCode with Swift 3?

60 views Asked by At

I apologise but I am relatively new to coding and venturing into typing up my own customisations of a flappy bird game. I have made two customisable buttons, for the bird and for the background. The bird button is fully functional but when the game runs and if I have clicked the background button on the main menu it has changed in the game but the button itself does not change on the main menu? Any help would be much appreciated, thank you!

import Foundation

class GameManager {

    static let instance = GameManager();
    private init() {}


    var birdIndex = Int(0);
    var birds = ["Blue", "Green", "Red"];


    func incrementIndex() {
        birdIndex += 1;
        if birdIndex == birds.count {
        birdIndex = 0
        }
    }

    func getBird() -> String {
        return birds[birdIndex];
    }



    var backIndex = Int(0);
    var backs = ["Day", "Night", "Preme"];

    func otherincrementIndex() {
        backIndex += 1;
        if backIndex == backs.count {
        backIndex = 0;
        }
    }

    func getBack() -> String {
        return backs[backIndex];
    }



    func setHighscore(highscore: Int) {
        UserDefaults.standard.set(highscore, forKey: "Highscore");
    }

    func getHighscore() -> Int {
        return UserDefaults.standard.integer(forKey: "Highscore");
    }

}

The customisable bird button does work but the background one doesn't. Is this problem going to be caused by this section or the Gameplay scene? Thank you again in advance.

0

There are 0 answers