I want to test for transition from one state to another. I have defined my states in an enum like this:
enum FingerStatus {
FINGERS_UP,
MOVING,
FINGERS_STILL
};
I have a "currentState" and a "newState" variable. I know that enums are just integers, and if they're 16-bit integers, which I think they are, it's possible to represent two enums as a single 32-bit integer.
I feel like I ought to be able to do something along the lines of
switch ({currentStatus, newFingerStatus}) {
case {FINGERS_STILL, MOVING}:
NSLog(@"fingers starting to move");
break;
case {MOVING, FINGERS_STILL}:
NSLog(@"fingers stopped moving");
break;
default:
break;
}
I realize the syntax is all wrong, but I think the basic idea is sound. Is there another nice, clean way to do this?