Dialog/Text Display Help

0 favourites
  • 2 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I've been working on creating a function to create a text box and display text I pass into it, but so far I'm not having luck. It works for the first time then when it's called the game just freezes.

    Does anyone have any advice about how to pause the game to display a text box and then click to change it one or more times, then click again to get rid of the box and resume the game? Thanks!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • If you are storing your texts in an array, it could look like this:

    dialogmode = 0

    function "displaydialog": set dialogmode = 1, system set timescale = 0

    • system create object dialog box
    • system create object text
    • text set text to array.at(x,0)
    • set (instance variable) text.nexttext to array.at(x,1)

    mouse clicked AND dialogmode = 1

    IF text.nexttext not equal to -1:

    • set text to array.at(text.nexttext,0)
    • set text.nexttext to array.at(text.nexttext,1)

    IF text.nexttext = -1:

    • destroy dialog box
    • destroy text
    • set dialogmode = 0
    • system set timescale = 1

    When you call the function you pause the game (timescale), we set a variable to identify in which state the game is in (dialogmode = 1), which you could add as condition to other events that might interfere with the dialog.

    then the dialog box and text are created. I assume we only have 1 instance of those in the layout - if not, you'd need to pick the correct instance each time you wanna work with it.

    It sets the text to the proper tex to display and in the array we also have stored which text to display next. The next text to display is stored in the text's instance variable nexttext and when we press on it the text gets changed accordingly. If nexttext is -1, it means the dialog is over and the game continues, so the dialog box and text are destroyed and game's state is set to the way it was before.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)