Dialog/Text Display Help

Get help using Construct 2

Post » Thu Nov 28, 2013 1:15 am

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!
Posts: 6
Reputation: 187

Post » Thu Nov 28, 2013 1:40 am

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.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
Posts: 788
Reputation: 3,788

Return to How do I....?

Who is online

Users browsing this forum: dop2000, mcscooter and 29 guests