嘿我试图检查我的播放器类中的边界框是否与我的地图图块的边界框相撞。然而它提出了这个错误。我在map.h中有一个名为Player playermap的定义;包括我的玩家h。我然后检查他们是否相交,说mapplayer.boundingbox.intersects(platformboundingbox)然后发生碰撞。看一看,任何见解将不胜感激
这是我的地图类的一部分
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;
答案 0 :(得分:0)
问题是你的
using namespace sf;
这会使您的变量Window
与sf::Window
类发生冲突。
使用例如
this->Window.Draw(...);
或(我推荐)停止使用using
语句。在声明中编写代码只需要四个字符,并且还可以使代码更清晰。