SFML community forums

Help => Graphics => Topic started by: Jamie on January 28, 2009, 10:11:36 am

Title: C++ writing out pictures from an array
Post by: Jamie on January 28, 2009, 10:11:36 am
Okay, this is what I am trying to do:

I want to get the program to write out the sprite that belongs to the coordinate. The names, (Mot, Des, and so on) is sprites who worked perfectly to write out before i tried the line:

App.Draw(pl

Which just seems like a good way to do it, as far as I can see...
Because I want to be able to move around amongst the sprites.

What am I doing wrong? Or how could i change it to make it work as I want?

Code: [Select]
int x=2;
int y=2;

string pl[x][y];

    pl[0][0]="Mot";
    pl[1][0]="Des";

    pl[0][1]="Lead";
    pl[1][1]="Wis";

App.Draw(pl[x][y]);


My compiler is Code Blocks.
Title: C++ writing out pictures from an array
Post by: Laurent on January 28, 2009, 10:59:22 am
What do you expect to happen when you pass a string to App.Draw? Where are your sprites?

Why did you post in the C forum? Why did you use the [ quote ] tags instead of [ code ]? :P
Title: C++ writing out pictures from an array
Post by: Tank on January 28, 2009, 11:05:01 am
At first: please always post the compiler error output.

I guess it says something like "no matching function for call to sf::RenderWindow::Draw(std::string&)", right?

The problem here is, that RenderWindow::Draw() takes one parameter of type sf::Drawable&, but you're using std::string here, which can't be converted into a Drawable&.

Instead of std::string, use sf::String, i.e. "sf::String pl
Title: C++ writing out pictures from an array
Post by: dewyatt on January 28, 2009, 11:07:41 am
:chuckles:
I can see how he could get confused though.
I always though sf::String should be sf::Text or something so it wouldn't be confused with a std::string like object.

Anyways, I believe what you're looking for Jamie is sf::String, not std::string.