Color recognition with switch/case

Asked

Viewed 35 times

0

In my code, I’m making a map in which one pixel for colored x, then the Sprite x will be put in it, example:

int pixelAtual = pixels[xx + (yy * map.getWidth())];
tiles[xx + (yy * WIDTH)] = new Floor_tile(xx*16, yy*16, Tile.TILE_FLOOR);

if(pixelAtual == 0xFF000000)

{
tiles[xx + (yy * WIDTH)] = new Floor_tile(xx*16, yy*16, Tile.TILE_FLOOR);
}

Meanwhile, I want to change the logic of if and else if for switch/case. How would I write the code for this - using the color hexadecimals for verification?

1 answer

0

See if this is what you need unfortunately I don’t quite understand what your doubt is if it is only the use of the switch follows below your conversion of if:

switch(pixelAtual)
{
    case 0xFF000000:
      tiles[xx + (yy * WIDTH)] = new Floor_tile(xx*16, yy*16, Tile.TILE_FLOOR);
    break;
}
  • That’s exactly what it was, Brigadier

  • For nothing, if it was solved do not forget to mark the answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.