0

嘿,我试图检查我的玩家类中的边界框是否与我的地图图块的边界框发生冲突。但是它出现了这个错误。我的 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;
4

1 回答 1

0

问题是你的

using namespace sf;

这将使您的变量与类Window发生冲突。sf::Window

要么使用例如

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

或者(我建议)停止using声明。在声明中只需要多写四个字符,而且还有一个好处是它可以让你的代码更清晰。

于 2013-04-11T17:11:43.383 回答