Outputting an Integer and Manipulating it.
What do you expect this line to do?:
Or more importantly, isn't this throwing an error at you as well? Because when I look at the SDL reference docs, the first argument of SDL_BlitSurface definitely isn't a std::string...
SDL_BlitSurface( creditString, NULL, screen, NULL);
Or more importantly, isn't this throwing an error at you as well? Because when I look at the SDL reference docs, the first argument of SDL_BlitSurface definitely isn't a std::string...
If you've had success blitting other surfaces to the screen, you have everything you need. The key points:
1) Turn an integer into a string using stringstream
2) Turn a string into an SDL Surface* using the TTF function.
So if your code still looks like it did in the last big code post, I'd suggest changing that SDL_BlitSurface call from (creditString, ...) to (output, ...) as creditString is your std::string from before, while output is a pointer to a surface (which is what SDL_BlitSurface expects as its first argument).
1) Turn an integer into a string using stringstream
2) Turn a string into an SDL Surface* using the TTF function.
So if your code still looks like it did in the last big code post, I'd suggest changing that SDL_BlitSurface call from (creditString, ...) to (output, ...) as creditString is your std::string from before, while output is a pointer to a surface (which is what SDL_BlitSurface expects as its first argument).
std::stringstream ss;
ss << score;
std::string creditString = creditString.c_str();
SDL_Surface* output = TTF_RenderText_Solid(font, creditString.c_str(), textColor);
SDL_BlitSurface (output, NULL, screen, NULL);
apply_surface(150, 150, output, screen);
This is what is looks like and nothing is showing.
ss << score;
std::string creditString = creditString.c_str();
SDL_Surface* output = TTF_RenderText_Solid(font, creditString.c_str(), textColor);
SDL_BlitSurface (output, NULL, screen, NULL);
apply_surface(150, 150, output, screen);
This is what is looks like and nothing is showing.
One question, are you blitting the text to the screen before or after you blit the background image to the screen?
Try replacing the line
SDL_Surface* output = TTF_RenderText_Solid(font, creditString.c_str(), textColor);
with
SDL_Surface* output = TTF_RenderText_Solid(font, ss.str().c_str(), textColor);
SDL_Surface* output = TTF_RenderText_Solid(font, creditString.c_str(), textColor);
with
SDL_Surface* output = TTF_RenderText_Solid(font, ss.str().c_str(), textColor);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement