我遵循以下教程:
Mouse and keyboard input
如果删除与DirectX相关的所有内容,我不会收到任何错误。若我使用指针insted,那个么我会得到一个错误,表明我的inputhandler构造函数被删除了。有什么想法吗?
h类
#pragma once
#include <Windows.h>
#include "DirectXTK-master\Inc\Keyboard.h"
#include "DirectXTK-master\Inc\Mouse.h"
class InputHandler
{
public:
InputHandler();
InputHandler(HWND wndHandle);
~InputHandler();
void updateInput();
private:
std::unique_ptr<DirectX::Keyboard> keyboard;
std::unique_ptr<DirectX::Mouse> mouse;
};
cpp公司
#include "InputHandler.h"
InputHandler::InputHandler()
{
}
InputHandler::InputHandler(HWND wndHandle)
{
keyboard = std::make_unique<DirectX::Keyboard>();
mouse = std::make_unique<DirectX::Mouse>();
mouse->SetWindow(wndHandle);
}
InputHandler::~InputHandler()
{
}
void InputHandler::updateInput()
{
auto kb = keyboard->GetState();
if (kb.Escape)
PostQuitMessage(0);
auto mouseState = mouse->GetState();
}