Well, if you wanted to use a literal [icode]String[/icode], you have to have some method to “parse” it, hence why it will always be less efficient (and shoddy) than just an indexed table.
It could be simple:
Map<String, TextureRegion> texMap;
draw(texMap.get("player_0" + playerLife));
Of course this is stupid.
Using actual variables, and no Strings, just using a different form of table:
TextureRegion player_01, player_02, player_03;
TextureRegion toUse = null;
switch (playerLife) {
case 1:
toUse = player_01;
break;
case 2:
toUse = player_02;
break;
case 3:
toUse = player_03;
break;
}
draw(toUse);
I think is close to what you meant, but there are no macros or similar in java to generate this code for you. I hope you see that this is still quite unnecessarily painful.
The equivalent is this as shown earlier:
TextureRegion[] textures;
draw(textures[playerLife]); // or if a more complicated mapping is required: textures[mapFunc(playerLife)]
The real question: why would you have separate variables to begin with? Ideally you have an array (or List, etc) from the start, and this whole thing becomes a non-issue.