C++ DirectX11 visual studio 2012.我已將GKController1類聲明爲ref類。 我是C++編程的新手,我沒有編寫大部分代碼,所以我不明白爲什麼它會突破。如果你需要更多的代碼,只需要問。謝謝。DirectXGame.exe中0x00B84CD6未處理的異常:0xC0000005:訪問衝突讀取位置0x000000DC
在此處,它打破了代碼:
Background.cpp文件
int GameBackGround::PlayingGame()
{
if (this->controller1->IsPauseRequested()) //Breaks here, it doesn't even allow me to step into the method, it just breaks
{
//Game Paused
return 3;
}
}`
Background.h文件
GKController1^ controller1;
//GKController1 file
bool GKController1::IsPauseRequested()
{
if (gamepadConnected)
{
if (this->gamepadState.Gamepad.wButtons & XINPUT_GAMEPAD_BACK
&& !(this->previousGamepadState.Gamepad.wButtons & XINPUT_GAMEPAD_BACK))
{
return true;
}
else
{
return false;
}
}
else
{
return this->escKeyPressed;
}
}
沒有看到更多的代碼我會說你可能試圖從空指針值訪問內存偏移量。在開始嘗試修復某人的代碼之前,最好先熟悉該語言的基礎知識。總之,如果'controller1'是一個指針,並且包含對象允許一個狀態,那個成員變量可以是一個空指針值,你需要在訪問它指向的內存之前檢查它。 –