你好,我有未定义基类的问题
这是我的基础和继承头文件
基类
#pragma once
#include "GameStateManager.h"
class GameEngine;
class GameStateManager;
struct tagMSG;
class GameState
{
public:
GameState() {}
virtual ~GameState() {}
virtual void Enter(GameEngine *) = 0;
virtual void Update(tagMSG& msg, GameStateManager* game) =0;
virtual void Exit() = 0;
};
派生类
#pragma once
#include "GameEngine.h"
#include "GameState.h"
#include "MainMenu.h"
class Logo :public GameState
{
public:
Logo();
~Logo();
void Enter(GameEngine * engine);
void Update(tagMSG& msg, GameStateManager* game);
void Exit();
private:
float timer;
GameEngine * m_GameEngine_Info;
SceneActor * blackscreen;
SceneActor * digipen_logo;
SceneActor * team_logo;
};
游戏状态管理器
#include "Logo.h"
#include "MainMenu.h"
#include "Level.h"
class GameState;
class GameStateManager
{
public:
GameStateManager(GameEngine* engine);
~GameStateManager();
void Cleanup();
void ChangeState(std::string state);
void Update(tagMSG & msg);
bool Running() { return m_running; }
void Quit();
private:
std::unordered_map<std::string, GameState *> states;
GameState * current_state;
bool m_running;
GameEngine * m_engine;
};
我正在尝试为我的游戏引擎做游戏状态,请参考
和
http://gamedevgeek.com/tutorials/managing-game-states-in-c/
更新
“游戏-> ChangeState(“ mainmenu”)”中的错误1
void Logo::Update(tagMSG& msg, GameStateManager* game)
{
m_GameEngine_Info->Update(msg);
if (m_GameEngine_Info->InputCheckTriggered(CVK_ESC))
{
timer = 0.0f;
}
while (timer >= 0.0f)
{
if (timer <= 0.1f)
{
game->ChangeState("mainmenu");
}
else if (timer <= 5.0f)
{
if (team_logo != nullptr)
team_logo->SetOnlyActive(true);
if (digipen_logo != nullptr)
digipen_logo->SetOnlyActive(false);
}
--timer;
}
}
更改状态函数,状态为unordermap current_state是GameState *
void GameStateManager::ChangeState(std::string state)
{
current_state->Exit();
current_state = states.find(state)->second;
current_state->Enter(m_engine);
}
答案 0 :(得分:0)
在基类中包含GameEngine.h 在Logo.h中包含GameStateManager.h
似乎没有正确包含头文件。