2017-07-30 35 views
0

蛇のゲームを作成しようとしていて、何かの理由でゲームオーバーになるまでうまく動作します。かなり私は63行目にexeptionを追跡するために管理し、しかし、私はそれが動作するように取得するように見えるいけない、srryイムC++例外がスローされました:VS2015の0xDDDDDDDDとしての読み取りアクセス違反

#include "Game.h" 
using namespace sf; 

Game::Game() 
    :actualStateID(END) 
{ 
    ContextSettings settings; 
    settings.antialiasingLevel = 8; 
    window.create(VideoMode(SCRN_WIDTH, SCRN_HEIGHT), "Snake", Style::Close, settings); 
    window.setFramerateLimit(60); 
    window.clear(); 
    window.display(); 

    if (!font.loadFromFile("data/font.ttf")) 
    { 
     //MessageBox(NULL, "Font not found! Chceck data folder!", "ERROR", NULL); 
     return; 
    } 

    actualStateID = MENU; 
} 


Game::~Game() 
{ 
} 

void Game::runGame() 
{ 
    actualState = new MenuState(MENU, window, font); 
    actualState->init(); 

    while (actualStateID != END) 
    { 
     if (actualStateID != actualState->getSTATE_ID()) 
      changeState(); 

     handleState(); 
    } 
    window.close(); 
} 

void Game::changeState() 
{ 
    delete actualState; 

    switch (actualStateID) 
    { 
    case MENU: 
     actualState = new MenuState(MENU, window, font); 
     break; 
    case PLAY_STATE: 
     actualState = new PlayState(PLAY_STATE, window, font); 
     break; 
    case FAILURE: 
     //Image screenShot = window.capture(); //DEPRECATEDDDDDD 
     //Image screenShot = Texture.update(window); 

     //actualState = new FailureState(FAILURE, window, font, screenShot); 
     break; 
    } 

    actualState->init(); //error line!! 
} 

void Game::handleState() 
{ 
    actualStateID = actualState->handleEvents(event); 
    actualState->update(); 
    actualState->render(); 
} 

:ここactualState->

はactualStateに取り組んでCPPファイルのコードですC++とsfmlの新機能

ここでstate.cpp f ILEだけでなく、詳細なエラー(VisualStudioをのいずれかの詳細がありますか?): error image with state.cpp はPCの前にあまりにも多くの時間、uncomented actualstate、気にしないで、事前

答えて

0

でお願いします=とfailurestateコードを変更します。

関連する問題