Cooldown and boolean change when layout changes

0 favourites
  • 6 posts
  • So I have a clicker game, 4 resources. At the top of the page are 4 tabs, you tap each tab to switch to the resource. (each resource page has its own layout). Each layout has a white circle sprite that you click to earn the resource.

    So I have a variable, 'IsTappable' and when it's true the circle is white and you can click it to earn the resource which sets the boolean to false. This runs a function which gives x number of resources and runs a cooldown of x seconds, using a global cooldown variable for each resource and sets 'IsTappable' back to true. Basically, when the boolean is false the circle is grey.

    However, if I switch tabs during cooldown of the resource when I switch back to said resource layout the boolean is stuck false and the circle is grey.

    Any help would be greatly appreciated. :)

    Thanks, Max

  • I would say use Timer behavior, but since you need to switch between layouts, then I guess global variables is a better choice.

    Instead of the boolean, use a numerical variable that will store the time when cooldown should end. For example for 3 seconds cooldown set CoolDownEnd to (time+3)

    To check if the cooldown has ended, compare CoolDownEnd<time

  • Thank you for your quick response! When I get home I will try this out and let you know what happens!

  • I'm sorry but i'm a noob at construct, but I tried to attempt what you suggested but I have no idea how to do it.

  • You'll need a different cooldownEnd variable for each button.

    If you have many buttons, it will be easier to store their cooldown counters in a dictionary or array. You can add all buttons to a family and re-use the same couple of events and functions for all of them.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Honestly, thank you so much! That is so simple yet so effective! The code is perfect and I appreciate your help so much. I'll need to start learning about arrays then:)

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