The errors I get are:
In constructor 'Player::Player(sf::Sprite&)':
error: no match for call to '(sf::Sprite) ()'Brief code with certain things that don't matter omitted (like the RenderWindow and other event stuff).
#include <SFML/Graphics.hpp>
using namespace sf;
class Player
{
private:
int bbox_top, bbox_bottom, bbox_left, bbox_right; //collision for all sides of the player sprite
public:
Player(Sprite& playerSprite); // or (const Sprite& playerSprite) not sure if the const is needed
~Player();
};
Player::Player(Sprite& playerSprite)
{
bbox_top = playerSprite().getLocalBounds().y;
bbox_bottom = playerSprite().getLocalBounds().height;
bbox_left = playerSprite().getLocalBounds().x;
bbox_right = playerSprite().getLocalBounds().width;
}
int main()
{
Texture playerTexture;
playerTexture.loadFromFile("player.png");
Sprite playerSprite(playerTexture);
Player player;
}
I'm referencing the sprite, so I don't get why I'm getting these errors. It doesn't matter if I use const in the Player constructor parameter or not, I still get the error. I even tried different names in the parameter list, like
Sprite& ps.I know this is more of a C++ question than SFML, but it is related to the sprites. I don't get why it's not working.
If you know the answer, you're a life saver. Thank you.