Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Problem with SFML and sprites...  (Read 1887 times)

0 Members and 1 Guest are viewing this topic.

bacondude95

  • Newbie
  • *
  • Posts: 11
    • View Profile
Problem with SFML and sprites...
« 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.

eigenbom

  • Full Member
  • ***
  • Posts: 228
    • View Profile
Re: Problem with SFML and sprites...
« Reply #1 on: February 04, 2014, 06:26:39 am »
Read up on pointers in C++. :)

Code: [Select]
sprite2.getTexture()->getSize().x

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: Re: Problem with SFML and sprites...
« Reply #2 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 '->' ?)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/