Where are you calling "font->draw(...)"? It should be somewhere after "smgr->drawAll()" and before "driver->endScene()" in order to render the text on top of your scene objects and while the screen is still open for drawing.
You can use font->draw like you are, but it is better to use
str += core::stringw(score);
so it is a string, otherwise it might get added as a char which is no good. Also, it would be better to use a GUI static text element and just change its text.
Ion Dune wrote:Where are you calling "font->draw(...)"? It should be somewhere after "smgr->drawAll()" and before "driver->endScene()" in order to render the text on top of your scene objects and while the screen is still open for drawing.
It worked Thanks a lot Ion.
DtD wrote:You can use font->draw like you are, but it is better to use
str += core::stringw(score);
so it is a string, otherwise it might get added as a char which is no good. Also, it would be better to use a GUI static text element and just change its text.
I used 'core::stringw()' as you suggest. I didn't see a way how to change GUI static text. I read the 'addStaticText' Function reference, it say that I can use 'SetText()' to alter the text, but I can't find it in the reference.
weeix wrote:'addStaticText' Function reference, it say that I can use 'SetText()' to alter the text, but I can't find it in the reference.
IGUIStaticText is derived from IGUIElement, so you can also use all the functions in there (look at the inheritance diagrams on top of the class documentation).
I read with interest the post but some points are still unclear to me (...being an Irrlicht newbie!).
Specifically, I have the same problem of weeix: I want to display the score (e.g. "Player 1: 3000 points"), that is, I would like to display a string consisting of a string ("Player 1:") appended to a (casted) variable ("3000") appended to a string ("points"). In this regard I am asking:
1) why is it better to use a GUI static text? Is it a question of memory usage?
2) how is it possible to change GUI static text?
3) how you solved the problem with setText (can you post some example code)?
1 because when using a GUI statictext you can change the value of the text at any time during the scene and it will be drawn during the next guienvironement->drawall();
2 yes using settext()
3 as far as i know there is no issue about the methode only the OP could not find the documentation about it