I have an SKLabel attached to a parent SKNode and an array of strings:
let configText:[String] = [
"Configuration",
"Do stuff",
"Do more stuff",
"Nil",
"It is the void"]
The array is looped through with the following:
parentNode_Label.run(
SKAction.sequence([
SKAction.run{
if self.counter == self.configText.count - 1
{ self.counter = 0 } },
SKAction.wait(forDuration: 3.0),
SKAction.run { self.sprite_Label.text = self.configText[self.counter + 1] },
SKAction.fadeIn(withDuration: 0.5),
SKAction.wait(forDuration: 3.0),
SKAction.fadeOut(withDuration: 0.5),
SKAction.run{ self.counter += 1 }
]).forever()
)
extension SKAction
public func forever() -> SKAction { return SKAction.repeatForever( self ) }
}
It works but seems kind of clunky/hacky. Is there a simpler, more efficient yet readable way to do this?