SFML community forums
Help => General => Topic started by: David on May 30, 2011, 09:27:37 pm
-
I got the linkage to work, but got a little problem with the collision itself.
if (Collision::BoundingBoxTest(const sf::Shape& Main, const sf::Shape& Ground)){
gravity *= -1;
}
Gave me:
"error: expected primary-expression before 'const'"
I'm not that good at using references, seeing that there's one there.
-
You're mixing a function declaration with an actual call.
Declaration:
bool Collision::BoundingBoxTest(const sf::Shape& Main, const sf::Shape& Ground);
Call:
Collision::BoundingBoxTest( main_shape, ground_shape );
Whereas main_shape and ground_shape are both sf::Shape objects that get automagically referenced (due to the function's signature).
Maybe start with a beginner's C++ book, it's rather basic knowledge.
-
I already tried that earlier and got this:
error: no matching function for call to 'Collision::BoundingBoxTest(sf::Shape&, sf::Shape&)'|
-
I just looked at the page for sf::Collision. It accepts two references to sf::Sprite, not two references to sf::Shape, hence the error - the compiler tells you that there is
no matching function for call to 'Collision::BoundingBoxTest(sf::Shape&, sf::Shape&)
because there is no such function.
See here: http://www.sfml-dev.org/wiki/en/sources/simple_collision_detection
Your other code is not solving the problem, merely masking it with a more fundamental problem.
EDIT:
Maybe start with a beginner's C++ book, it's rather basic knowledge.
If you don't want to buy a book:
http://www.cplusplus.com/doc/tutorial/