Making messageboxes only visible for a few seconds?

For questions about using Classic.

Post » Fri Jul 23, 2010 2:37 am

Is it possible? For example, I have a powerup object. When the character overlaps the object and presses Up, it destroys the powerup, sets the messagebox text to its 'DJText' private variable, and makes the Messagebox and messagetext visible.

That works fine, but the message stays there hovering in the air forever, or until you walk over another value-related item. Is there a specific way to make it so the messagebox stays visible for only a few seconds, say, three, then go back to being invisible?
Posts: 17
Reputation: 759

Post » Fri Jul 23, 2010 2:38 pm

There's always many ways to accomplish anything in programming, but here's how I'd do it.

Create a group called "KillMBox" and set it to be disabled upon startup.
In that group, use Trigger Once to set a private variable to 3.
Then, every second, subtract one from the private variable, and check to see if it's zero.
If it is, then hide/destroy the message box and disable the group.

Here it is:

The good thing about this approach is that when you decide to display the message box, you simply enable the group KillMBox and it will look after everything else, including shutting itself down when it's finished.

If you want to use it for multiple message boxes then you'll need to adjust the code to check each instance of the message boxes, destroying each one as it's needed to be, and only disabling the group when there are no instances of message box left.

And of course, you can always change the values of the checking and the private variable to get exactly the timing you want.
For instance, checking every 100 msecs and setting the private variable to 23 will display the message boxes for 2.3 seconds. :)

Hope that helps,
Posts: 406
Reputation: 2,062

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests