首先在AppDelegate.cpp加入以下代码,一定要在AppDelegate::applicationDidFinishLaunching()上,声明用的。
- #if(CC_TARGET_PLATFORM==CC_PLATFORM_WIN32)
- HelloWorld*g_layer;
- voidWin32SetKeyLayer(HelloWorld*layer)
- {
- g_layer=layer;
- }
- voidWin32KeyHook(UINTmessage,WPARAMwParam,LPARAMlParam)
- {
- CCLog("Win32KeyHookmessage%dwParam%dlParam%d",message,wParam,lParam);
- if(g_layer)
- g_layer->onWin32KeyEvent(message,lParam);
- }
- #endif
在AppDelegate::applicationDidFinishLaunching()中
copy