Need help with dialogs in Godot

SyettiSyetti Posts: 17Member
edited October 2016 in GUI

I need help with dialog without addons got any suggestions?

Answers

  • KioriKiori Posts: 202Admin

    Moved to GUI category and fixed the "hey need help" generic title.
    Please be more descriptive in the title and on your posts.

    "I need help" doesn't do you much good when people don't know what your problem really is.

  • zadigzadig Posts: 28Member

    When you say "help with dialogs" do you mean "a space to display text content ingame" or something else? As Kiori said, be more specific, your question probably has a nice and not so hard answer :). Give us some context (like "an 2d space shooter with text during cut-scenes" or "menu dialogs dealing with inventory").

  • RossRoss Posts: 199Member

    Was there a problem with that addon you tried?

  • SyettiSyetti Posts: 17Member
    edited October 2016

    Ya Ross

  • SyettiSyetti Posts: 17Member

    zadig i need help with a box where i can display text with a font that is interactive, as in a mouse click will make it go into different dialogs.

  • zadigzadig Posts: 28Member
    Answer ✓

    There are a few many ways of doing it. Here' one (hardcoded text content however)
    ·Create a Sprite2D that will act as the box holding your text.
    ·Create a RichTextLabel as a child node.
    ·Size and place things up according to your needs
    Via script you store your possible text values inside an array, like:
    var texts = ["text 1", "text2" etc]
    ·Assign a script to your parent sprite where you can access your rich_text, something like
    onready var speech_content = self.find_node("RichTextComponent")
    now you can change it's value via a simple assign operation:
    speech_content.set_bbcode(texts[1])
    (place it inside a function and code it according to the rules you see necessary)

    Of course this is a very simplified example. You'll still need to track the mouse clicks and call your function, deal with the opacity of the Sprite so it may vanish when not used, stuff like that.
    If you need to deal with texts originated from other game objects you will have to deal with signals.
    If you got lost try to watch a few tutorials about arrays and simple programming definitions.
    Hopefully this will be enough to get you going!

  • RossRoss Posts: 199Member
    Answer ✓

    For the box itself I think it would be easiest to use Godot's UI stuff and make a custom button. That way the mouse and keyboard stuff pretty much works for you right off the bat. Your standard multiple-choice dialog box is just a menu with buttons after all. For my menus I used a custom button scene with a root TextureButton and a Label and stuff on that (you probably want RichTextLabel like zadig said).

    The tricky part will be building a system to manage the dialog tree that is flexible and easy to use . . .

Sign In or Register to comment.