About Text.
About Text.
I want to show text when open the door(with out key), get a key, etc.
I use addStaticText() to draw. but when i want to change text , i can't change it because i don't know function for change text. i would like to know that addStaticText() have function to change text? and have function to move this text? if addStaticText() can't do that, what function can do it?
Thank you
I use addStaticText() to draw. but when i want to change text , i can't change it because i don't know function for change text. i would like to know that addStaticText() have function to change text? and have function to move this text? if addStaticText() can't do that, what function can do it?
Thank you
I do this code
but it's error and close windows. What's wrong?
Code: Select all
IGUIElement* text3;
text3->setText(L"555...");
text3->setRelativePosition (core::rect<s32>(100,10,184,99));
text3->draw();
I don't belive the setText method will do what you are asking because you have defined text as type IGUIElement. Which has a setText() method to set the caption of the element. I think you would have to define it as type IGUIStaticText which overrides the setText() method to set the text of the string. Am I right?
IGUIStaticText* text;
text = env->addStaticText(L"Text",rect<s32>(10,10,500,28), false,true);
// text will be shown as "Text"
text->setText(L"blah");
// text will now be "blah"
EDIT: Just tried it and i'm wrong, you can have it as IGUIElement and still change the text with setText, but you lose the color override function. Commence playing Price is Right loser theme here.
IGUIStaticText* text;
text = env->addStaticText(L"Text",rect<s32>(10,10,500,28), false,true);
// text will be shown as "Text"
text->setText(L"blah");
// text will now be "blah"
EDIT: Just tried it and i'm wrong, you can have it as IGUIElement and still change the text with setText, but you lose the color override function. Commence playing Price is Right loser theme here.
I saw in doc of engine that
"text is the text to be displayed. Can be altered after creation with SetText(). "
and I do this
error C2039: 'setText' : is not a member of 'IGUIEnvironment'
and I know that setText is member of IGUIElement but i don't know how to use this code.
"text is the text to be displayed. Can be altered after creation with SetText(). "
and I do this
Code: Select all
text1 = irrDevice->getGUIEn();
text1->addStaticText(L"You must find a key to open this door. ",core::rect<s32>(110,10,300,20), true, true, 0, -1, true);
if(...)
{
text1->setText(L"555");
}
and I know that setText is member of IGUIElement but i don't know how to use this code.
addStaticText() returns a pointer to the IGUIStaticText object within your GUIEnvironment, so assign a IGUIStaticText object to that returned pointer and use the object's setText method to change the text:
For readability and less confusion:
Code: Select all
text1 = irrDevice->getGUIEn();
IGUIStaticText* text = text1->addStaticText(L"You must find a key to open this door. ",core::rect<s32>(110,10,300,20), true, true, 0, -1, true);
if(...)
{
text->setText(L"555");
}
Code: Select all
IGUIEnvironment* env = irrDevice->getGUIEnvironment();
IGUIStaticText* text = env->addStaticText(L"You must find a key to open this door.", core::rect<s32>(110,10,300,20),true,true,0,-1,true);
if(...)
{
text->setText(L"555");
}
*bands head on table*fon3m wrote:I saw in doc of engine that
"text is the text to be displayed. Can be altered after creation with SetText(). "
and I do thiserror C2039: 'setText' : is not a member of 'IGUIEnvironment'Code: Select all
text1 = irrDevice->getGUIEn(); text1->addStaticText(L"You must find a key to open this door. ",core::rect<s32>(110,10,300,20), true, true, 0, -1, true); if(...) { text1->setText(L"555"); }
and I know that setText is member of IGUIElement but i don't know how to use this code.
Do yourself a favour and learn C++ before starting on stuff that's too complicated for you!
I get lectured at when I tell people this. Apparently I am critisizing peoples learning methods when I try to let people understand that Irrlicht is a rendering engine that uses C++, not that Irrlicht is a rendering engine that teaches C++.JP wrote:Do yourself a favour and learn C++ before starting on stuff that's too complicated for you!
I know, i'm turning into a bad man and hating n00bs which is wrong because we were all there once. But i just really think that a lot of these errors are simply from a lack of understanding of the language so basically just going to a website with some explanations and tutorials would do a world of good! Here's some that i used when i started changing over from Java to C++ earlier this year:
http://www.cplusplus.com/doc/tutorial/
http://www.cprogramming.com/tutorial.html
http://www.cplusplus.com/doc/tutorial/
http://www.cprogramming.com/tutorial.html