-
multiple cases
How would I check for multiple values in a switch case? This is for a function that increments to the next frame of an animation, it takes in two variables: the current frame (Position) and whether this is a left foot forward or right foot forward step (Footing). I've listed the code for what I'm trying to do:
switch (Position)
{
case 0:
if (Footing==0)
{
return 1;
}
else if (Footing==1)
{
return 6;
}
break;
case >=1 && <=4 //this is where I'm not sure of the syntax
if (Footing==0)
{
return Position + 1;
}
else if (Footing==1)
{
return Position - 1;
}
break;
}
In the case that Position is 1 to 4, I check the current step and then increment or decrement accordingly. Thanks in advance for any help you can give.
-
> case >=1 && <=4 //this is where I'm not sure of the syntax
No you can't do that
Just list them all as
case 1:
case 2:
case 3:
case 4:
// case 1 to 4 code here
break;
-
Thanks
Thanks a ton, Salem. I'm making the transition from VB to C/C++ so I keep getting stuck where I know what I want to logically but I don't know the proper C/C++ syntax. Thanks again.