Creating a Text Field for in-game dialogs as in WoW (AS3.0)

Started by
5 comments, last by jeteran 11 years, 8 months ago
Hi everybody, it's good to be here.

I'm trying to make a small game that has some good dialogs, some of them are speaked by the main character and some others by NPC.

So I thought I can make a text field very similar to the one used in World of Warcraft, where texts are display in different colors and keeps adding as character talks.

stella_wow.png
In this case, text is displayed in the right-corner of the game.

Is there a good way to do this? I'm not looking to do something complex. Just an area that keeps tracks of all the dialogs said during the game.

I'm totally new to AS3 but I'm a fast learner. I'm reading/studing right now the Rozensweigh's book.

Thank you SO MUCH for your time. It's good to be back around gamedev.net !!

JET
Advertisement
Obviously, a TextField gets populated with a string text. Are you asking how to color the text ?

In this particular case, I'd suggest that you use the htmlText functionality of a TextField. This would also require some coding to prepare the string appropriately with tags etc.

An example of doing so can be found here : http://www.ilike2fla...our-in-as3.html
Hey prototypical thanks so much for your response.

About coloring the text, the idea you gave me plus the example helps me a lot, thank you.

My other concern is about the Text Field. How can I add strings that goes one behind the next? and the old ones be pushed up?

I will try to do it by myself, but if you have any idea, it's very welcome.

Thank so much for your time prototypical !!

JET
You might want to use a (FIFO) queue of TextFields to get that effect. Push new ones to the end of the queue, test whether or not the oldest draws outside the top of your text box (of so, dequeue it), and render them from oldest to youngest.
Good to know greenvertex, thanks so much for your response.

BTW, do you know any good tutorial or guide that can teach me about the FIFO queue? I know what FIFO means but I don't think I know how to use it in the AS3, any ideas?

Thanks once again !!
I don't know that I would have a queue of textfields. I would probably have just one textfield sized to the dimensions of the chat window and just update that with a generated HTML text string each time an update is needed. The source data might be stored in a queue/list/array. But before you even get to that, you need to think about what kind of data you are storing, and how it will be used.

I assume that you'll be storing what someone chats, and possibly other notifications as well. The type of message will most likely determine the color of the text. right ?

There are multiple ways you might approach this. One might be a simple array that stores strings. Each string would be an html encoded version of the text, with the appropriate formatting for color/font/bold.

But even with that approach, you might have to consider what other requirements your chat widget might have. For instance... What if it needs to filter messages ? Like you might have the ability to only see a certain kind of notification/message based on a criteria that might or might not even be "custom" based on user preferences.

You can see how that design aspect might completely change the data and the way you handle the data, to facilitate only displaying the ones desired. Because now you need to be able to make logical decisions and it might not be enough to just store a string, but you might also need to store other data defining the purpose of the string (chat message, notfication, npc message etc)

I say all this, because as you will learn, sometimes just deciding to do something by perceived steps without evaluating the full scope of your design goal... can lead to alot of extra work in redesigning to facilitate new functionality you introduce.

In terms of learning, I'd not focus on just FIFO. I'd suggest that you explore arrays/list to start and then move to different methodology in organizing them etc.

You can google "Arrays AS3 Tutorial" and maybe "FIFO AS3 Tutorial" to search for resources.

As a note, I think that these forums are of great use for specific issues, but am not a fan of threads where you have a goal of creating a widget and go through the step by step development and all it entails in a single thread. So I'd suggest that you post topics that are not so broad, and focus on the specific issue at hand. ie -- FIFO. That way someone looking for information on FIFO in these forums is likely to find a useful discussion on that topic with any answers someone might give on that topic (links to tutorials ect) and not the development of a chat dialog widget.

In my opinion, the topic of this thread has been resolved as it has given information on how to create a textfield with color formatting, a general suggestion as to using a queue for storing the data, and a note about the importance of design in what approach you might choose with a widget like this.

Hope that doesn't come across as rude! smile.png Good Luck my friend.
Hey prototypical, thanks so much for your explanation, and NO OFFENSE TAKEN !!

Yes sorry about not specifying the subject; I just was looking a general guide to approach it.

But awesome !! What you told me makes more sense to mee, I will keep working on it and when I get, I will post it here ;)

Thanks once again prototypical !!!

This topic is closed to new replies.

Advertisement