C++ DirectX11 visual studio 2012. I have declared my GKController1 class as a ref class. I am new to C++ programming and I didn't write most of this code so I don't really understand why it's breaking. If you need anymore code just ask. Thanks.
Here's the code where it breaks:
Background.cpp file
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 file
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;
}
}
if (this->controller1->IsPauseRequested()) //Breaks here, it doesn't even allow me to step into the method, it just breaks
controller1
is almost certainly a bad pointer. When you dereference it (->IsPaurRequested()
) you receive an access violation because you are reading memory you don't own.
Where are you initializing it? I see the declaration, but you need to initialize it somewhere. The member is of the same type as the declaring class. Why is it needed? It looks like you're just passing everything through, why not just use IsPauseRequested()
(this->IsPauseRequested()
)?
User contributions licensed under CC BY-SA 3.0