Sprites spawning immediately - not after set time

Discussion and feedback on Construct 2

Post » Wed Jul 24, 2013 9:02 am

Hi! I believe I found a topic about it a few days ago but can't find it via the search again.

I created a few random spawntimers but sometimes (on new game or after restarting it after GameOver) both types of enemies spawn immediately at the beginning of the layout.
Does anyone know why or how to fix this?

B
53
S
16
G
6
Posts: 718
Reputation: 9,150

Post » Wed Jul 24, 2013 10:22 am

I see your "Reset Layout" is disabled. You need to reset it for the timer to restart.



Which version are you using?

I remember the previous versions had an issue where "Every X seconds" timer would not reset, even after layout reset, so that it would execute again the first moment it's available.

I believe that's why Ashley added the Timer behaviour instead, try to use that.Xionor2013-07-24 10:23:43
B
10
S
3
Posts: 233
Reputation: 1,537

Post » Wed Jul 24, 2013 10:39 am

I remember having that problem with a game, never fixed it but I really didn't know what I was doing :p One thing if suggest is destroying UFO on start of layout (or after waiting 0.1 seconds or something) destroying any UFO sprite. Not sure if it'd work but it's an idea, not a fix but it may hide the problem.
B
22
S
4
G
1
Posts: 71
Reputation: 8,321

Post » Wed Jul 24, 2013 11:26 am

All objects are already destroyed on startup (when layout loads).
I have 139 (Personal) and I tried restarting the level with Reset Layout first but I changed it to go back to the title screen on Game Over. Thats why I disabled it. So I need to reset it before jumping back?
/update: Enabling the Restart layout skips the jump to Title action and just restarts. So where should I place it? In "On Start of Layout" it creates a loop. Isn't switching to another Layout and then coming back the same as a "restart"?

When coming back to the title screen I noticed that an object which should have Opacity 0 is visible as well even if I add "On start of layout > set Opacity 0". I try if the Reset Layout fixes this.
Bl4ckSh33p2013-07-24 11:44:32
B
53
S
16
G
6
Posts: 718
Reputation: 9,150

Post » Fri Jul 26, 2013 6:06 pm

Still having problems with the visible object even if On Layout Start > Set Invisible is enabled but its only a minor thing.

The main problem is why is random 10,20 sometimes executed immediately when the layout starts? Is there some kind of bug or what am I missing?

And it seems "Every X sec" uses a global timer because on the credits screen I have "every 15 sec" and "trigger once" but sometimes its executed after 3-5 seconds. So every x sec is a global thing?
I added a global variable TIMER as a workaround and set it to 0 by default and add +1 every 1 sec after loading the credits layout. Is there another way to make this work?
B
53
S
16
G
6
Posts: 718
Reputation: 9,150

Post » Fri Jul 26, 2013 6:15 pm

If you post a capx I'll be glad to have a look for you :)
B
28
S
8
G
5
Posts: 429
Reputation: 6,997

Post » Fri Jul 26, 2013 6:17 pm

Thanks, I will try to create a copy of the layout where this happens so I don't have to post the whole game. I will post it tomorrow.
B
53
S
16
G
6
Posts: 718
Reputation: 9,150

Post » Sat Jul 27, 2013 7:00 pm

I am uploading the file right now.
you can find it here: http://www.playbird.at/sites/Bl4ckSh33p/soft/moonraccoon/MoonRaccoon_CodeExample.capx

Controls:
A and D to move left/right, W to fire laser
OR Cursor keys
and SPACE to fire rockets.

I added a debugframe showing time in sec and fps and I noticed that FPS drop from 60 to 30 and below after about 40 seconds of gameplay. I added a few "trigger once" and global vars to try to reduce how many checks are made every tick but I assume it will be checked afterwards as well so it does not really reduce the amount of checks.

And when you fire a rocket with space the game is stuck for a moment as well. I tried to show the particles for it off screen on the title screen and it seemed to help a bit but its still happening.

Any idea why it starts to lag after a while? Bl4ckSh33p2013-07-27 19:01:28
B
53
S
16
G
6
Posts: 718
Reputation: 9,150

Post » Sat Jul 27, 2013 7:05 pm

oops, forgot to remove the Clay.io plugin. Don't know if you need it to load it. You can download it here: http://clay.io/docs/construct2Bl4ckSh33p2013-07-27 19:12:35
B
53
S
16
G
6
Posts: 718
Reputation: 9,150

Post » Sat Jul 27, 2013 7:17 pm

Please post your questions in the how do I section ...

For the timer , I think the timer fires once and then starts counting
I'm not sure about this ...

You could try and fix it by adding a global boolean (TimerSet) to the object

And add the following script to your game

Ontop of your every X seconds condition
Add Is TimerSet

and just below your spawning scripts
Trigger once
-- Set TimerSet to true

I am not sure if that fixes the problem , but you could try it out !
B
41
S
17
G
17
Posts: 2,247
Reputation: 17,436

Next

Return to Construct 2 General

Who is online

Users browsing this forum: R0J0hound and 2 guests