游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1570|回复: 1

键盘检测问题

[复制链接]

42

主题

137

帖子

137

积分

注册会员

Rank: 2

积分
137
发表于 2007-8-18 11:39:00 | 显示全部楼层 |阅读模式
下面的程序可以运行但怎么检测不到esc键呢?目的是按esc退出。
#include "ExampleApplication.h"
#include "ExampleFrameListener.h"

class myListener: public ExampleFrameListener {
public:
        myListener (RenderWindow* win, Camera* cam)
                :ExampleFrameListener (win, cam, false, false) {}

        bool frameStarted (const FrameEvent& evt)
        {
                //if (!mKeyboard->buffered())
                        if (processUnbufferedKeyInput (evt) == false)
                                return false;
                return true;
        }
        bool processUnbufferedKeyInput(const FrameEvent& evt)
        {
                if (mKeyboard->isKeyDown (OIS::KC_Q))
                        return false;
                return true;
        }
};

class myExample: public ExampleApplication {
        void createScene () {}
#if 1
        void createFrameListener ()
        {
                mFrameListener = new myListener (mWindow, mCamera);
                mRoot->addFrameListener (mFrameListener);
        }
#endif
};

#include "windows.h"


int WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, int)
{
    myExample app;

    try {
        app.go();
    } catch( Exception& e ) {
        MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!",
            MB_OK | MB_ICONERROR | MB_TASKMODAL);
    }

    return 0;
}

42

主题

137

帖子

137

积分

注册会员

Rank: 2

积分
137
 楼主| 发表于 2007-8-18 16:05:00 | 显示全部楼层

Re:键盘检测问题

原来要先加mKeyboard->capture();
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-25 10:32

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表