"Every 5 seconds" conditon problem with layouts

0 favourites
  • 9 posts
From the Asset Store
For problem solving, puzzles, bubbles, platforms and other adventures.
  • Hi,

    I have a Main Title Screen Layout, and once clicked player goes to Layout 02.

    At the beginning of Layout 02 I have a condition: "Every 5 seconds" - spawn a box.

    Problem is, when I wait in the Main Title Screen Layout 5 seconds or more, and then click to go to Layout 02, the box is spawned already.

    So it seems that the timer - the "Every 5 seconds" condition is counting when the player is still in the Main Title Screen Layout

    How can this be? Am I doing it wrong? Is there another way to to make the "Every 5 seconds" condition work only after entering a layout?

    Thanks for the help.

    Edit: I tried to look for a condition: "On entering layout", but in the end couldn't find it.

  • Solomon

    do the layouts share the same event sheet?

    there is an event "On Start of Layout"

    I had a similar issue that I thought might be some kind of bug, but turned out it was an error in my code. So, I would think there is something you are doing that is causing this - and it is impossible to say what it is without seeing your code.

  • "Every X seconds" don't work as "per layout". It counts using the game time from the start.

  • Solomon

    do the layouts share the same event sheet?

    there is an event "On Start of Layout"

    I had a similar issue that I thought might be some kind of bug, but turned out it was an error in my code. So, I would think there is something you are doing that is causing this - and it is impossible to say what it is without seeing your code.

    Hmm interesting... didn't know that layouts can share 1 event sheet. I am going to do some reading on this now.

    Sorry what I mean I cant find an "If Start of Layout" event or how to implement it as such.

    Thanks for the tips will do some more reading and if I dont manage to solve my problem will post a snippit of my code.

  • "Every X seconds" don't work as "per layout". It counts using the game time from the start.

    Oh wow... Really? Thats a bummer... any other simple condition to wait until a layout is loaded? Could you please share any other tips on how I can solve this matter?

    Thanks!

  • There is no straight answer to that. It all depends what you want to achieve.

    You could use a Timer behavior, Groups, check if 5 seconds have passed for current layout etc.

  • shinkan

    I see... interesting.

    Basically, I want a box to spawn every 5 seconds after a layout is loaded.

    I have a title screen on 1 layout, during which I don't want anything to happen. I have it set that by clicking on it the player goes to another layout, which upon entering, after every 5 seconds a box is spawned.

    Edit: Only thing I cant set up is the part where the spawn timer starts only once the player enters the second layout.

    So basically:

    _____If Layout B is loaded

    ________Every 5 seconds spawn box

  • Solomon - another way is to use a global variable:

    On Start of Layout B --> set NextSpawnTime = Time + 5

    then, instead of every 5 seconds:

    System Compare two values ( Time >= NextSpawnTime ) --> spawn box, and set NextSpawnTime = Time + 5

    The only thing to watch out for is if you pause the game (or open a settings menu, or display a message) - you would have to save the remaining wait time:

    TimeToSpawn = NextSpawnTime - Time

    then when you unpause, set NextSpawnTime = Time + TimeToSpawn

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Solomon - another way is to use a global variable:

    On Start of Layout B --> set NextSpawnTime = Time + 5

    then, instead of every 5 seconds:

    System Compare two values ( Time >= NextSpawnTime ) --> spawn box, and set NextSpawnTime = Time + 5

    The only thing to watch out for is if you pause the game (or open a settings menu, or display a message) - you would have to save the remaining wait time:

    TimeToSpawn = NextSpawnTime - Time

    then when you unpause, set NextSpawnTime = Time + TimeToSpawn

    OH WOW! Thanks a lot for your time! Now I have to wrap my head around it

    How much simpler would it be to have the ability just to toggle the "Every 5 seconds" condition to either start counting at beginning of game, or start counting at beginning of each layout?

    Construct 2 is great don't get me wrong, but it is seemingly simple things like this that just put me off for a bit once in a blue moon.

    Anyhow once I get this working by your example I'm sure this logic structure will come in handy in some other part of my game.

    Once again thanks for your time

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