尝试将引擎从SDL重写为SFML,sf::RenderWindow的范围是错误的
Try to rewrite engine from SDL to SFML, wrong scope of sf::RenderWindow?
我的显示图像有问题(我试图将引擎从 SDL 重写为 SFML 2.0;引擎下载自:http://gamedevgeek.com/tutorials/managing-game-states-in-c/)
我对 introstate.cpp 中的那部分代码有问题。
程序编译并创建窗口(仅一秒钟),然后消失,没有任何反应,也没有渲染任何内容(它应该显示图像)。
我认为这与对象范围有关 sf::RenderWindow MarioClone。我的意思是它是在几个标题中声明的,并在各种方法中使用,所以我认为指向创建的特定窗口存在误解。我应该使用"extern"关键字somwhere还是什么?
我留下了指向 github 的链接,因为代码在许多文件中,甚至一个文件包含大量代码并且不想将其粘贴到此处(很难阅读)。https://github.com/shahar23/MarioClone(是的 - 代码有以前的原始 SDL 注释,以便轻松理解应该在方法中放入什么)
在游戏引擎.cpp文件的init
方法中,创建一个与头文件中声明的变量同名的局部变量。那不是你想要的。您要更改现有变量:
void CGameEngine::Init(const char* title, int width, int height, bool fullscreen)
{
// This line creates a NEW LOCAL variable of the same name.
// Your instance level variable remains unchanged:
// sf::RenderWindow MarioClone(sf::VideoMode(width, height), title, sf::Style::Default);
// instead, change your class level variable:
MarioClone.create(sf::VideoMode(width, height), title, sf::Style::Default);
相关文章:
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 代码在main()中运行,但在函数中出现错误
- 释放错误后堆使用
- (C++)分析树以计算返回错误值的简单算术表达式
- Project Euler问题4的错误解决方案
- 当我尝试绘制 sf::Text 对象时,SFML 中的分段错误
- SFML 中的分段错误 调用 sf::窗口::关闭后
- sf::声音函数会导致链接器错误
- 侦听器.Accept将错误传递给sf :: tcpsocket时给出错误
- SFML 套接字 发送数据包时设置为 sf::套接字::错误
- 尝试将引擎从SDL重写为SFML,sf::RenderWindow的范围是错误的
- 错误 LNK2001:未解析的外部符号"public: static class sf::RenderStates const sf::RenderStates::Default"
- 错误 C2248:'sf::NonCopyable::NonCopyable'
- C++ SFML 编译错误 sf::不可复制::不可复制(const sf::不可复制&) 是私有的