Make buttom reappear every X seconds

0 favourites
  • 8 posts
From the Asset Store
Like tourists, Travel around the world as fast as you can!
  • Hello, just having a little change in the way my game runs and would like a button that can currently be touched over and over again to only be able to be touched again after X seconds. For testing purposes I have made a Sprite counting down from 10-1 every second.

    The problem I'm facing is that the first part works - the initial button gets destroyed and replaced with the counting down sprite. However, I cannot get the original button to respawn or destroy the counting down sprite. I have sat here for an hour experimenting but just cant get it to work.

    Any pointers or am I looking in the wrong ball park? The initial Wait 0.3 to destroy the healthboostbutton is there just incase touch is prolonged on the button causing unwanted character movement. Cheers

  • You want to spawn a new button after 10 seconds? "Time=10 seconds" is the wrong way to do it. This condition compares the time passed since the game startup, not since the last action.

    A simple way to fix it is to add "Wait 10 seconds", but I advise against using Wait with such a long timeout, because in 10 seconds many things can change. It's much safer to use Timer behavior. Or if your countdown sprite is animated, you can use an event "CountdownSprite On animation finished" to spawn a new button and destroy the countdtown sprite.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Dop, thanks for your reply again bud. Thanks for the pointers and yes I now see how I was telling the whole system to wait 10 seconds. After following your advise, and going over the manual countless times I am still stuck! All I can get it to do is to destroy the health button, spawn the animated sprite, the countdown lands at 1 and.. nothing. Numerous attempts, I'm obviously missing something!

    No matter which was I do it, I cant get that animated sprite to spawn the health button again or destroy itself. I'll send some snippets that I've been trying (I've tried about 60 variations so far) but still cant get it to work, and not sure how I can do animated Sprite on animation finished as an event, unless inverting which as you'll see I've tried.

    Also tried with a variables instead but came across some bumps there!

  • Change your code like this:

    And note, that "On animation finished" needs to be a top-level event, not a sub-event!

  • If you are using a Timer, you need "On Timer" event, not "is timer paused". And it also needs to be top-level event. Why are you trying to put everything into a sub-event?

  • To be honest I didnt even realise I was using a sub event there, I've been using my phone to do the alterations today. Just had a quick look and can now see the on timer event (as it's on a new top level event) so I'll have another play around. Cheers dop

  • Its destroying the animated sprite! Hurray! However, the spawn new object (healthbutton) is spawning for a brief second then disappearing

  • Got it sorted, got the system to create new button, works perfectly. Thanks for your help dop

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