本文介绍了SFML getGlobalBounds().intersect(getGlobalBounds()不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是试图从shipshape和asteroidshape那里发生碰撞,但是getGlobalBounds没有发生任何事情.我在做错什么吗?请帮我.在Spaceship.hpp中有一个布尔函数.很奇怪,但是我需要创建任何变量以引用getGlobalBounds吗?
I just try got collsion from shipshape and asteroidshape but getGlobalBounds nothing happning.Im doing anything wrong? please help me.In Spaceship.hpp have a bool function.Very strange but the i need create any variable for reference to getGlobalBounds?
我只是在这里输入了Spaceship.cpp的代码以进行澄清.
I just put a code here from Spaceship.cpp for clarify.
Spaceship.hpp
.....
class Spaceship: public sf::Drawable, public sf::Transformable {
......
public:
bool shipcollisionAsteroid(sf::ConvexShape shapeship, sf::ConvexShape shape);
.......
.......
private:
sf::Convexshape shapeship;
};
#endif
//==================================================
Spaceship.cpp
#include "Spaceship.hpp"
....
......
.....
sf::ConvexShape shape; // same name in private Asteroid,hpp BUT NOT WORKING
if ( shapeship.getGlobalBounds().intersects(shape.getGlobalBounds())){
reset(); // its a function for reset Spaceship on screen
}
推荐答案
您可以发布更多代码吗?仅查看此片段很难发现问题.显示您的小行星文件
Can you post more code? It's hard to find the problem only looking at this snippet. Show your asteroid file
这篇关于SFML getGlobalBounds().intersect(getGlobalBounds()不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!