Timed events start before I get to right layout

Get help using Construct 2

Post » Tue Sep 17, 2013 1:23 am

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!33miles2013-09-17 01:26:29
B
8
S
1
Posts: 42
Reputation: 1,159

Post » Tue Sep 17, 2013 1:27 am

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.
B
9
S
3
G
1
Posts: 191
Reputation: 1,725

Post » Tue Sep 17, 2013 7:36 am

Thanks ryackov! I'll try that out and let you know how it goes.
B
8
S
1
Posts: 42
Reputation: 1,159

Post » Tue Sep 17, 2013 8:30 am

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

Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Tue Sep 17, 2013 11:46 am

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
B
12
S
5
G
2
Posts: 132
Reputation: 2,627

Post » Thu Sep 19, 2013 1:16 am

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!
B
8
S
1
Posts: 42
Reputation: 1,159

Post » Thu Sep 19, 2013 1:24 am

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. plinkie2013-09-19 01:24:57
B
45
S
15
G
73
Posts: 2,008
Reputation: 43,398

Post » Sat Sep 21, 2013 11:27 am

@plinkie 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!
B
8
S
1
Posts: 42
Reputation: 1,159

Post » Sun Sep 22, 2013 2:50 am

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.

B
45
S
15
G
73
Posts: 2,008
Reputation: 43,398

Post » Wed Oct 16, 2013 3:47 am

@plinkie

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!   
B
8
S
1
Posts: 42
Reputation: 1,159

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests