In my libgdx code, i'm using the message handling features that this library offers, the only thing i must say is: why ints?
In my project i have this class:
public enum MSG {
DIALOGUE_TRIGGERED,
DIALOGUE_DONE,
BLOCK_WALLS,
...;
public int code;
static {
int counter = 0;
for (MSG msg : MSG.values()) {
msg.code = counter++;
}
}
}
It's an enum that auto assigns a code.
Then, each time i have to work with messages i do:
public void send(MSG msg) {
stageMsg.dispatchMessage(msg.code);
}
or
@OverRide
public boolean handleMessage(Telegram msg) {
if(msg.message == MSG.SWAP_FIGHT_STATE.code) swapFightingState();
return true;
}
Is there a specific reason for why it must be a int with no "built in" way to use strings or enums?
If there isn't i would be more then happy to implement it myself if necessary.
In my libgdx code, i'm using the message handling features that this library offers, the only thing i must say is: why ints?
In my project i have this class:
public enum MSG {
DIALOGUE_TRIGGERED,
DIALOGUE_DONE,
BLOCK_WALLS,
...;
public int code;
static {
int counter = 0;
for (MSG msg : MSG.values()) {
msg.code = counter++;
}
}
}
It's an enum that auto assigns a code.
Then, each time i have to work with messages i do:
public void send(MSG msg) {
stageMsg.dispatchMessage(msg.code);
}
or
@OverRide
public boolean handleMessage(Telegram msg) {
if(msg.message == MSG.SWAP_FIGHT_STATE.code) swapFightingState();
return true;
}
Is there a specific reason for why it must be a int with no "built in" way to use strings or enums?
If there isn't i would be more then happy to implement it myself if necessary.