SFML - Intersects

Hi, I have a problem with intersects , skip the following error:

error: 'class sf::RectangleShape' has no member named 'intersects'|


Code:

1
2
3
4
5
6
7
8
9
10
11
sf::RectangleShape rec(sf::Vector2f(50, 50));
    rec.setFillColor(sf::Color::Cyan);

   
    sf::RectangleShape rec2(sf::Vector2f(50, 50));
    rec2.setFillColor(sf::Color::Magenta);
    rec2.setPosition(400, 300);

if(rec.intersects(rec2)){
            std::cout << "Toca" << std::endl;
        }


Guide me appreciate if they knew
Thanks greetings.
Last edited on
sf::RectangleShape doesn't have a member named 'intersects'. sf::Rect does.
Determining whether two sf::RectangleShapes intersect is non-trivial, because a sf::RectangleShape may be rotated. If you consider that two rectangles are intersecting each other when one completely surrounds the other, then you need a convex polygon clipping algorithm. Otherwise, you need a convex polygon intersection algorithm.

If the rectangles will always have their sides aligned with the axes, just use sf::Rect instead.


Guide me appreciate if they knew
"They"? The government?
Last edited on
Topic archived. No new replies allowed.