I am trying to change the location of an image, and to do that I need a certain variable, which I initialized at the start of this code. I am able to call the variable multiple times with no problem, expect for the second time I call it, on line 7. The exact error is "Variable 'currentHall' must be initialized." How can I fix this?
var currentHall: Hall
for (i in 0..11) {
if(halls[i].name == locationHall) {
currentHall = halls[i]
}
}
if (currentHall.image == "segment_hori.png") {
youAreHere.y = currentHall.yCoord
youAreHere.x = currentHall.xCoord + locationCoords
}
if (currentHall.image == "segment_vert.png") {
youAreHere.y = currentHall.yCoord + locationCoords
youAreHere.x = currentHall.xCoord
}