SFML community forums

Help => Graphics => Topic started by: bacondude95 on February 04, 2014, 06:08:35 am

Title: Problem with SFML and sprites...
Post by: bacondude95 on February 04, 2014, 06:08:35 am
Whenever I try compiling the code(Which is handling collision between two sprites) I get an error.

This is only a portion of what I'm having a problem with, and yes it's all linked, libraries are included and everything.
It even compiled succesfully before but when I modified what happens when an error occurs (Texture failed to load, font failed to load, etc) it came up with a problem here.
If any more information is needed please ask.
bool Collision::SpritetoSprite(sf::Sprite sprite, sf::Sprite sprite2)
{
    if(sprite.getPosition().x < sprite2.getPosition().x + sprite2.getTexture().getSize().x && sprite.getPosition().x > sprite2.getPosition().x &&
       sprite.getPosition().y < sprite2.getPosition().y + sprite2.getTexture().getSize().y && sprite.getPosition().y > sprite2.getPosition().y)
    {
        return true;

    }else
    {
        return false;
    }

}
 


And the error:
C:\Users\Nicholas\Desktop\Projects\SFML2.1 Game\Collision.cpp

line:|30|

error: request for member 'getSize' in 'sprite2.sf::Sprite::getTexture()', which is of pointer type 'const sf::Texture*' (maybe you meant to use '->' ?)|

 
The error also appears for line 31.
I have no idea what this error is implying or how to fix it.
Title: Re: Problem with SFML and sprites...
Post by: eigenbom on February 04, 2014, 06:26:39 am
Read up on pointers in C++. :)

Code: [Select]
sprite2.getTexture()->getSize().x
Title: AW: Re: Problem with SFML and sprites...
Post by: eXpl0it3r on February 04, 2014, 08:20:48 am
Seriously, do you even read the error? Have you tried to understand it? Did you like google the error?
I mean the compiler even suggests what you should do! ;)
error: request for member 'getSize' in 'sprite2.sf::Sprite::getTexture()', which is of pointer type 'const sf::Texture*' (maybe you meant to use '->' ?)