Timed events start before I get to right layout

0 favourites
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • Hello again everyone. I have a question for you if you could spare a second or two. I have 8 layouts so far, the first one is a start screen, then I have 4 containing each page of my story. The next one is a tutorial and after that my main level layout starts. My last layout is a game over screen. Now my problem is that for my main level layout I have many timed events such as:

    (condition (system, every 30 seconds) = (action (create object "robot" on layer 2 (x12751,y430)

    And after progressing through the 6 beginning layout screens the timing of all those events are messed up like they had started when I was on the start screen. I don't think I could add "at start of layout" to any of them because they need to be going constantly through the main level once it starts and wouldn't that condition make the event untrue after the first cycle? Does anyone know a trick to add to my events that would fix this? Thanks, and I appreciate every bit of your help!<img src="smileys/smiley1.gif" border="0" align="middle" />

  • I suggest making a parent condition that says at start of layout, and making those every 30 seconds events to be sub-events of that parent condition.

  • Thanks ryackov! I'll try that out and let you know how it goes. <img src="smileys/smiley20.gif" border="0" align="middle" />

  • I don't think that will work because start of layout will only be triggered once.

    If it doesn't work, try this:

    Create a global variable (e.g. 'timestamp') and set inital value to a high value (e.g. 999999). Create a start of layout event in the affected layout's event sheet. Set the action to fill the global with the current time

    + start of layout -> Set timestamp to time

    All your every-x-seconds-events then have to be subevents to the following compare event:

    + time >= timestamp

  • I was thinking of the same as tulamide, expect I would use a boolean variable instead of comparing time: initialize the variable to false, set it to true on layout start, and check if it's true every-30-seconds. Just bit simpler IMO

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the responses everyone. I tried using a boolean variable and it kinda works... For some reason one wave of enemies from the sub-events fires off almost instantly upon start of layout, after that their timing is about right. Does anyone know why it makes all of them just spit out on start up like that?

    I now have an event that sets the LayoutStart GlobVariable from 0 to 1 on start of layout. Then I have another event comparing the variable to 1 but it does not have an action is this okay? And finally I have sub-events under the compare variable to 1 event for all my x seconds enemy spawns. Does that sound like it should work? Thanks again and hopefully I'll get this working!

  • Most events run every tick unless they are defined with conditions. What is the parent event of the sub-events that are incorrectly starting on start of layout?

    If the compare does not have an action I guess this is saying when LayoutStartVar is set to 1 then do/change nothing.

  • Hey plinkie, the parent event of my sub-events is just:

    (system) compare variable, LayoutStart = 1) with no action

    So I guess it's not doing anything huh? I wanted to do it tulamide's way but with a boolean instead of a large number, unfortunately I had trouble fully understanding it. Could you or tulamide explain it to me in really simple steps please? The way I write my events in my posts is kinda how I perceive them if that makes any sense. Thanks for all your patience guys. Please respond soon, thanks!

  • Your issue here is that it's spawning objects while you can't see the layout. Is this right? The game will run events for all layouts even if you're on a different layout if the conditions are true, so events such as every X seconds will be running even when you can't see the layout.

    Please explain what you would like to happen. A .capx or screenshot of the events would be good.

    If you have set up an event that checks if you're on a given layout before triggering the sub-events then this should work. If it's not working as expected then it is set up incorrectly and we probably need to see how you have set up the events.

  • Hey plinkie and everyone! Sorry responding took a long time, I have been very busy lately. Here is a test .capx for the problem I am still facing.

    SpawnTest1.0

    You will notice that enemy spawn times are different if you start from the menu (layout 1) than if you start from layout 2 the actual game scene. So please check it out for me. I set up a global variable text that is initially set to off, but when the yellow block falls on the player at the beginning of the layout it sets it to on. I tried to make my events so that the enemies only start to spawn once the variable is on but it still doesn't work properly. Basically I only want my spawn events to start when layout 2 is started, if you guys could help me out with this I would be extremely happy. Thanks much in advance!   <img src="smileys/smiley1.gif" border="0" align="middle">

  • Wouldn't it be easier to use the timer behaviour, set the timer to thirty seconds and on timer create enemies and set timer again?

  • Basically I only want my spawn events to start when layout 2 is started, if you guys could help me out with this I would be extremely happy. Thanks much in advance!   <img src="smileys/smiley1.gif" border="0" align="middle" />

    Try this:

    <img src="http://i39.tinypic.com/255nl15.png" border="0" />

    It's not so different from your approach.

    Have fun.

  • Thanks for the suggestion moonworx, but it did not work for me. I set it up just like your screenshot and it played just like the way it was originally. Thanks anyway! Do you have any other ideas? <img src="smileys/smiley38.gif" border="0" align="middle" />

    LittleStain

    I don't have much experience with timers. Could you explain in a bit more detail how I could make this work the same way by using them? I really appreciate it!

    Thanks and please respond soon!

  • I could try to explain the timer behaviour, but this link will do

    Scirra Manual: Timer behaviour

    in essence you can decide, when the timer starts (and for what period of time) and what should happen when the timer ends. So if you set the timer for thirty seconds you could set the creation of enemies on timer end and restart the timer for thirty seconds and repeat and repeat....

    So every thirty seconds the enemies would be created, but you can adjust everything through events and conditions ofcourse.

  • Hey LittleStain! Thanks for getting back to me so quickly. I read the link you supplied and tinkered a bit but am still not knowing how to use these properly. My main problem is that I am unsure of how to set up a timer event that spawns an enemy in a certain place, the conditions and actions just don't seem to be available where I would think they should be. Like I can't use the condtion (on start of layout) and have the proper timer actions to go along with it. Also after I learn how to do this will timers succeed where my every x seconds events failed?

    I'm just trying to get my enemies to start spawning at the proper time only when I'm on the actual level layout and not while I'm on the menu screen layouts. I don't really see why the original logic in my .capx that I shared on here didn't work...

    So please LittleStain could you give me a short little example of an enemy spawning event with timers just so I can see the process of how to form them? I'm sorry for all the questions, but I am very thankful for everyone who has replied. Respond when you can please, thanks much.<img src="smileys/smiley1.gif" border="0" align="middle"> Here is my demo .capx again for easy reference. SpawnTest1.0

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