|
|

楼主 |
发表于 2009-3-5 12:50:00
|
显示全部楼层
Re:有看过《DirectX游戏开发终极指南》的吗?
本人运行《DirectX游戏开发终极指南》书中的例子时遇到了问题:
出现了错误:
未处理的“System.NullReferenceException”类型的异常出现在 Stranded.exe 中。
其他信息: 未将对象引用设置到对象的实例。
为什么?高手们说说。这是有关一个directx的一个例子。提示出错的地方在:
m_device->SetProperty(DIPROP_RANGE, &range.diph);/////////
CGameController::CGameController(LPDIRECTINPUT8 input, HWND hwnd)
{
// Save copies.
gThis = this;
m_hwnd = hwnd;
m_inputSystem = input;
// Initialize the game controller.
DIPROPRANGE range;
DIDEVCAPS caps;
m_inputSystem->EnumDevices(DI8DEVCLASS_GAMECTRL, (LPDIENUMDEVICESCALLBACK)gJSEnumDeviceCallBack,
NULL, DIEDFL_ATTACHEDONLY);
if(m_device)
{
range.diph.dwSize = sizeof(DIPROPRANGE);
range.diph.dwHeaderSize = sizeof(DIPROPHEADER);
range.diph.dwHow = DIPH_BYOFFSET;
range.lMin = -1000;
range.lMax = 1000;
range.diph.dwObj = DIJOFS_X;
m_device->SetProperty(DIPROP_RANGE, &range.diph);/////////出错的这个
range.diph.dwObj = DIJOFS_Y;
m_device->SetProperty(DIPROP_RANGE, &range.diph);
if(SUCCEEDED(m_device->GetCapabilities(&caps))) m_numButtons = caps.dwButtons;
else m_numButtons = 4;
}
}
|
|