Direct Input?!

Started by
1 comment, last by kanguru 21 years, 8 months ago
How would you detect a key is down, and only take action for that down once? (once action per keypress) since DirectInput just return the state of the key. I tried if ((m_kKeyboard.IsButtonDown (DIK_SPACE))&&(m_fSpace==FALSE)) { DO SOMETHING; } to check if the key is down and take action here(where m_fSpace is just a flag), then if (m_kKeyboard.IsButtonUp (DIK_SPACE)) m_fSpace=FALSE; to reset the flag But when it come to running, I add a breakpoint to DO SOMETHING, my application break as soon as I start it. What is my problem? The funny (and flustraiting ) thing is I did quite a lots loop in my program when I remove some It run OK again! Anyone has any idea pls help! Thx [edited by - kanguru on August 14, 2002 4:53:32 AM]
Advertisement
if(dikspace){
if(!flag){
flag=true;
do something
}else{
do nothing cuz flag is true
}
}



.lick
I did assign my flag to TRUE.

This topic is closed to new replies.

Advertisement