For loop continue function

So I’ve been working on my app and recently figured out how to properly use a “loop while” function.
The problem I came across was I tried to understand the continue part of the loop, but Xcode kept saying the continue function is used only in a loop.

From the Swift Programming Language manual:

Would it work the same way if I were to implement it into my loading screen and have it jump to the next source function?

I’m not exactly sure what you mean

Hi Rusty,

Can you explain what you are trying to achieve and include some code examples of what you have tried so far that gives us some context as to why you want to use ‘continue’.

Okay, so I managed to use a repeat-while loop to make a loading screen when a player presses the play trigger.
Here’s what I have so far;

let progressBar = Line(start: Point(x: -50, y: -20), end: Point(x: -49, y: -20), thickness:2)
var gameHasLoaded = false
var loadingImage = Image(name: "GUNTER.exe.png")
private func _setupProgressBar() {
    loadingImage.add()
    loadingImage.scale = 4
    progressBar.add()
    progressBar.color = Color.orange.lighter()
}
private func loadGame() {
    let randomDelay = Int.random(in: 0..<35)
    if progressBar.end.x != 50 {
        animate(duration:2,delay:Double(randomDelay)) {
            progressBar.end.x += 0.5
            progressBar.end.y += 0
        }
    }else if progressBar.end.x >= 50 {
        progressBar.end.x += 0
        progressBar.end.y += 0
        gameHasLoaded = true
    }else if progressBar.end.x == 45 {
        animate(duration:2,delay:Double(randomDelay)) {
            progressBar.end.x += 0.1
            progressBar.end.y += 0
        }
    }else if progressBar.end.x == 48 {
        animate(duration:2,delay:20) {
            progressBar.end.x += 1
            progressBar.end.y += 0
        }
    }else if progressBar.end.x == 49 {
        animate(duration:10,delay:0) {
            progressBar.end.x += 1
            progressBar.end.y += 0
        }
    }else if progressBar.end.x == 50 {
        progressBar.end.x += 0
        progressBar.end.y += 0
        gameHasLoaded = true
    }
}
public func _loadGame() {
    _setupProgressBar()
    if gameHasLoaded == true {
        Canvas.shared.clear()
    }else {
        repeat {
            loadGame()
        } while gameHasLoaded == false
    }
    
}

Which will produce this loading screen.


The orange line at the bottom is the progress bar.
The point I’m trying to get the public func _loadGame() is when the progress bar reaches the “100%” point, it will launch the game itself.

do it inside a timer to update the progressbar