choose a character

hello, for a school project i have to create a fighting game. After displaying player 1's characters, I would like player 1 to select a character from their list. Can you help me ? thank you
Code Block Swift
func list() {
    print("here are the three characters :")
    for characters in Character {
      print("\(characters.charactersName), \(characters.weapon), \(characters.lifePoint)")
    }
  }


What is your problem ? Is it how to present the list of characters ?
If so, you have several solutions:
  • use a segmented control (may be the simplest)

  • insert directly in the view switches to select the character you want.

  • create an alert with a button for each selection

Please explain precisely

Note: I would not use Character here which is a reserved type.
OK, what would you have put in place of character?





Problem is not with character but Character.

You could simply use Characters
Code Block
for character in Characters {
print("\(character.charactersName), \(character.weapon), \(character.lifePoint)")
}

Could you show how youn definer the Character struct ?
choose a character
 
 
Q