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

Author Topic: C++ writing out pictures from an array  (Read 3460 times)

0 Members and 1 Guest are viewing this topic.

Jamie

  • Newbie
  • *
  • Posts: 1
    • View Profile
C++ writing out pictures from an array
« 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
  • [y]);


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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
C++ writing out pictures from an array
« Reply #1 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
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
C++ writing out pictures from an array
« Reply #2 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
  • [y]", and everything should work fine. sf::String is derived from sf::Drawable btw.

dewyatt

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
    • http://dewyatt.blogspot.com
C++ writing out pictures from an array
« Reply #3 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.

 

anything