我有3個值的枚舉:C++枚舉和OR條件
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
}
我缺少的東西?