Making messageboxes only visible for a few seconds?

This forum is currently in read-only mode.
From the Asset Store
Make your own platformer for both the web and mobile easy with this Santas Platformer Template, FULLY DOCUMENTED
  • 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?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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:

    <img src="">

    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,


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