Emtec
Member
|
How to display dialogs above the players?
I would like to print some text above the player. Is there any module, class which help to do that? I mean I have got a player and above this player some text is displaying. Thanks.
|
|
04-23-2014 09:23 AM |
|
AndrewBGS
Member
|
RE: How to display dialogs above the players?
I haven't done this myself, but this is what I would try:
You could use the posToScreen (I'm at work now, don't have the engine, but some function converting world space to screen space) to figure out where the head of the character talking is, and display the text a little above it. Display the text as a GUI text element so you can handle it's scale, and use that to centre it over the character, and scale the font with respect to the distance to that character.
This is just an idea, haven't tried it out.
|
|
04-23-2014 10:00 AM |
|
Rubeus
Member
|
RE: How to display dialogs above the players?
Depending on what you need it for, the ImgText library I created(available in the store under Source > Tools) may work for you.
You can see information about it here: http://www.esenthel.com/community/showth...p?tid=7513
One of the tutorials included is for putting a player's name above their head.
The library does not support multi-line text, though it can be done by making a second image below/above the first.
|
|
04-23-2014 04:54 PM |
|
Emtec
Member
|
RE: How to display dialogs above the players?
Rubeus you said "One of the tutorials included is for putting a player's name above their head." -> could you tell me the name of this tutorial? Thanks.
(This post was last modified: 04-23-2014 07:54 PM by Emtec.)
|
|
04-23-2014 07:54 PM |
|
TBJokers
Member
|
RE: How to display dialogs above the players?
"Some Texts". Alright here's what you do, either you choose the head bone, or create a bone, or you simply use the actors position + the height + text height + if there are other texts that it should be above.
Vec2 drawPos = PosToScreen(Players[0].pos());
drawPos += Vec2(0, Players[0].height + UNDEFINEDVARTEXTHEIGHT); //Could be 0.02, 0.08, 0.12, you would only know for your game.
D.text(drawPos,S + "Hello My Name Is : " + Players[0].name);
As if you might want more than this like a rectangle filled with text so that you can have a gradient filled in the background of the text you'd have to create a Rectangle. And they are very easily used with D.text later on.
That's my 5 cents ^^
(This post was last modified: 04-23-2014 10:10 PM by TBJokers.)
|
|
04-23-2014 10:09 PM |
|
Rubeus
Member
|
RE: How to display dialogs above the players?
(04-23-2014 07:54 PM)Emtec Wrote: Rubeus you said "One of the tutorials included is for putting a player's name above their head." -> could you tell me the name of this tutorial? Thanks.
It's one of them included with the ImgText library. Apologies for the confusion.
FYI, the ImgText library images that are created should render faster than a lot of D.Text calls. It also allows for adding effects to the text.
(This post was last modified: 04-24-2014 03:11 AM by Rubeus.)
|
|
04-24-2014 03:10 AM |
|