Call function for x times at random timing? [Solved]

0 favourites
  • 5 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • Hi All! I've been searching for similar situations that could help me solve my prob, but unfortunately i couldn't find anything to gave me an idea so i hope someone can help me out! Basically i want to call a function in my levels for a max of 3 times within 3 minutes but i want them as well to happen at random times, each within a timelapse of 20-60 seconds. I hope someone will come up with an idea! Thanks for your time guys and if it's not too clear what i'm trying to obtain just let me know

  • 20-60 second delays are quite long, so forget about using "Wait" action.

    Add Timer behavior to one of your objects (background sprite for example) and a variable "callCounter".

    Then you can do something like this:

    On start of layout
    [ul]
    	[li]> Sprite start Timer "CallFunction" for random(20, 60)[/li]
    [/ul]
    Sprite On Timer "CallFunction" 
    callCounter<3 
    [ul]
    	[li]> Add 1 to callCounter[/li]
    	[li]> Sprite start Timer "CallFunction" for random(20, 60)[/li]
    	[li]> Function call ...[/li]
    [/ul]
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Cool that sounds like the right approach for what i'm aiming at, thanks for your suggestion mate i'll try that!

  • It worked simply Perfectly! Thanks so much dop2000 you're great

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