Group Group Group Group Group Group Group Group Group

Enhancing BullsEye

Hi there,

I’m thinking of adding a small feature to challenge myself. I want to start a new game after n number of rounds, for this I thought of doing the below:

  1. capture the value of specific UILabel
  2. Check if it’s greater than n number
  3. If true start a new game, else keep playing.

I was able to do number 1, which came back as an optional(String), is it safe to change it’s type back to an int so I can compare? If no how do I check this, if yes, the new game button listens for an event of click i think, how can I do this automatically based on number of rounds, is this even possible?

Thanks in advance.

Hi rexorioko. Rather than trying to get the round number back from the Text item, why not just look at is as you’re about to increment it? Inside the dismiss button handler, there’s a chunk of code that looks like this:

self.score = self.score + self.pointsForCurrentRound() = Int.random(in: 1…100)
self.round = self.round + 1

So, at the point where self.round is incremented, try replacing that last statement with something like this:

if self.round < self.limit { self.round = self.round + 1) } else { self. startNewGame() }

In the above, I’m using “self.limit” as what you refer to as “n” in your question.