SFML平台错误:缺少类型说明符-假定为int

sfml platformer error: missing type specifier - int assumed

本文关键字:int 说明符 类型 错误 平台 SFML      更新时间:2023-10-16

嘿,我试图检查我的玩家类的边界框是否与我的地图贴图的边界框碰撞。然而,它提出了这个错误。我在我的map。h中有一个定义叫做playermap;在包含了我的玩家h.之后,我通过输入if mapplplayer .boundingbox.intersects(platformboundingbox)来检查它们是否相交,然后碰撞就发生了。看一看,如果有什么见解,我将不胜感激。

这是我的map类的一部分

if(mapVector[i][j] == 1)
                         {
                            sprite.SetImage(BlockImage);
                            sprite.SetPosition(j * BLOCKSIZE, i * BLOCKSIZE);
                            platformBoundingBox.Top = sprite.GetPosition().y - 5;
                            platformBoundingBox.Bottom = sprite.GetPosition().y;
                            platformBoundingBox.Left = sprite.GetPosition().x - 5;
                            platformBoundingBox.Right = sprite.GetPosition().x;
                            Window.Draw(sprite);    
                            if(mapPlayer.boundingBox.Intersects(platformBoundingBox))
                                cout<<"collision occured";
                         }

这里是我的map.h文件

出现错误的地方
Player mapPlayer;

问题出在你的

using namespace sf;

这将使您的变量Windowsf::Window类冲突。

任意使用,例如

this->Window.Draw(...);

或者(我建议)停止使用using语句。在声明中只需要多写四个字符,而且它还会使您的代码更加清晰。