Switch Statements

@richard, could you please add switch statements to block coding? it simplifies things like having many tilemaps, so that somebody isnt doing

if (a==1) {

} else if (a==2) {

} else if (a==3) {

} else…

but instead:

switch (a) {

1:

2:

3:

4:

2 Likes

You could just put the tilemaps in an array and then they would all be in order with less code like you’re wishing for.

2 Likes

Wait, that’s a thing?

3 Likes

Yup! Most C-style language have a switch() statement, JavaScript and TypeScript included. Useful … but not as widely used as it probably should be, perhaps because the syntax is a bit quirky.

2 Likes

I’m my game that I’m making, each “case” has a tilemap and something to set the platform speed, player start, etc. that would make it harder to make an array