Oh you mean about the switch statement, actually that’s what I eventually did, and it did work (the if/else). Quite oddly, with the switch, no errors were in the console, and the game kept running, even though what it turns out was happening was that way after the switch statement, I had something that would cause an error. With the if/else, the error showed up just fine (and also output all the debug statements, and stopped the game.) With the switch, the debug statements I had just after the case
began did not get flushed and yet the game kept running and no error was output. I still think there’s a bug there of some kind, because now that I’ve fixed the error-causing thing, I still need to use an if/else there otherwise my game is broken due to odd switch behaviour:
trace("starting out", _ui.currMode, _ui.currMode == "fairy_destination");
switch (_ui.currMode) {
case "optional_village":
trace("not here", _ui.currMode, _ui.currMode == "fairy_destination");
if (Std.is(itemClicked, Village)) {
var village = cast(itemClicked, Village);
if (village.side == ISLANDER) {
villageIndex = villages.indexOf(village);
setMode("fairy_destination");
}
}
case "fairy_destination":
trace("we should get here", _ui.currMode, _ui.currMode == "fairy_destination");
if (tileMap.getTile(clickedX, clickedY) != BigMap.colourMap.indexOf(FlxColor.BLUE)) {
destX = clickedX;
destY = clickedY;
setMode("plant_types");
}
default:
trace("not here 2", _ui.currMode, _ui.currMode == "fairy_destination");
setMode("general");
trace("not here 2 end", _ui.currMode, _ui.currMode == "fairy_destination");
}
trace("done the switch statement", _ui.currMode, _ui.currMode == "fairy_destination");
How is it possible that this outputs the following, on Firefox and Chrome both?
State_Play.hx:585: starting out,fairy_destination,true
State_Play.hx:604: not here 2,fairy_destination,true
State_Play.hx:719:
State_Play.hx:721:
State_Play.hx:725:
State_Play.hx:606: not here 2 end,general,false
State_Play.hx:608: done the switch statement,general,false
In particular, that second line makes no sense to me whatsoever. It went to the default
branch instead of the case "fairy_destination"
even though clearly _ui.currMode == "fairy_destination"
as seen in the trace output. If I step through with the debugger in the console, it indeed jumps from the switch down to the default, not even stopping on the case
lines (which is what happens in the Flash debugger, each case
line gets a step.)
Flash OTOH gives this output:
State_Play.hx:585: starting out,fairy_destination,true
State_Play.hx:597: we should get here,fairy_destination,true
State_Play.hx:719:
State_Play.hx:721:
[a bunch of normal output from setMode("plant_types") here, without errors...]
State_Play.hx:608: done the switch statement,plant_types,false