Restart of Match Game

Does anyone have suggestions how to restart the game tapping on OK of the alert message?
Apparently has already been asked but I don’t find any message in the community.

Hi Fillppo,

All I did was create a Bool called newgame and set the Bool to true at the end of the current game. Then added a condition to start game button to reset everything.

I also have three time levels the user can choose.

if newgame {
            model = CardModel()
            cardAarry = [Card]()
            cardAarry = model.getCards()
            seconds = gameChoice //user chooses one of three time levels.


1 Like

Hi Mark,
thank you for your help.
Sorry but I’m a real beginner and I’m not able to implement your hint.
As soon as I put the line
if new game {
I have the following message error

Where I have to start?

Hi Filippo,

No worries, I am too!

You need to create a class variable var newGame = false

After the game completes, you set the variable newGame to true and it will run your startup code again, above.


1 Like

also remove your "if(newgame { " its outside of any function thats why its causing an error

you can also just quick fix the missing protocol by letting xcode handle it