我有一个具有 3 个值的枚举:
enum InputState { Pressed, Released, Held };
我在这段代码中使用它:
//GetState returns an InputState
if(myInput.GetState(keyCode) == InputState::Pressed)
{
//This means "keyCode" has the state "Pressed"
}
为什么这不起作用?
if(myInput.GetState(keyCode) == (InputState::Pressed || InputState::Held))
{
//This is always false
}
if((myInput.GetState(keyCode) == InputState::Pressed) || (myInput.GetState(keyCode) == InputState::Held))
{
//This works as intended, triggers when "keyCode" is either Pressed OR Held
}
作为测试,我做了:
//Using the same values from the enum, but as int now
if(1 == (1 || 2))
{
//This works as intended
}
我错过了什么吗?