#if(CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include <windows.h> #define KEY_DOWN(vk_code) (GetAsyncKeyState(vk_code) & 0x8000 ? 1 : 0) #define KEY_UP(vk_code) (GetAsyncKeyState(vk_code) & 0x8000 ? 0 : 1) #endif
然后在UPDATE函数中调用
#if(CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) if(KEY_DOWN(VK_DOWN)) { // do something } #endif