I was getting this error using Eclipse.
Duplicate local variable cape
I really don't understand why I was getting such an error. This was my code:
switch (frame) { // frame is an integer
case 0:
Sprite cape = modules.get(Module.CAPE);
//cape.setRegion(region);
cape.translateY(+1);
break;
case 1:
Sprite cape = modules.get(Module.CAPE);
//cape.setRegion(region);
cape.translateY(-1);
break;
default:
throw new IllegalArgumentException(
"Undefined frame number: " + frame);
}
Why is it not true that the cape variable is local to each case, but instead to the switch statement?