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

Author Topic: Problems with GetImage()  (Read 1561 times)

0 Members and 1 Guest are viewing this topic.

Kamaitachi

  • Newbie
  • *
  • Posts: 28
    • View Profile
Problems with GetImage()
« on: March 15, 2011, 07:03:30 pm »
Why won't the following won't work?

Code: [Select]
sf::Image image[3];
sf::Sprite sprite[3];

void Field::FDImage(std::string filename, int arpos)
{
    if (!image[arpos].LoadFromFile(filename))
    {
        App.Close();
    }
    if (!sprite[arpos].SetImage(image[arpos]))
    {
        App.Close();
    }
}


The error returned is
Quote
C:\...\SFML_Project\main.cpp
||In member function 'void Field::FDImage(std::string, int)':
|C:\...\SFML_Project\main.cpp|52|error:
could not convert '((Field*)this)->Field::sprite[arpos].sf::Sprite::SetImage(((const sf::Image&)((const sf::Image*)(&((Field*)this)->Field::image[arpos]))))' to 'bool' in argument to unary !

devlin

  • Full Member
  • ***
  • Posts: 128
    • View Profile
Problems with GetImage()
« Reply #1 on: March 15, 2011, 07:12:25 pm »
The problem doesn't lie with GetImage, but with your syntax.

SetImage returns void, not bool. You can't use the result in an if-clause.

Kamaitachi

  • Newbie
  • *
  • Posts: 28
    • View Profile
Problems with GetImage()
« Reply #2 on: March 15, 2011, 07:36:21 pm »
Oh... d'oh! Thank you.