Sprites spawning immediately - not after set time

0 favourites
  • 12 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • Hi! I believe I found a topic about it a few days ago but can't find it via the search again. <img src="smileys/smiley19.gif" border="0" align="middle" />

    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?

    <img src="http://www.fotos-hochladen.net/uploads/spawntimerprobd24ah73lty.jpg" border="0" />

  • 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.

  • 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.

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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?

  • If you post a capx I'll be glad to have a look for you :)

  • 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.

  • 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?

  • 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/construct2

  • 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 !

  • Any idea why it starts to lag after a while?

    You're creating a lot of HUDRocket sprites. See in event 22 it's constantly creating new sprites when RocketsAvailable > 0. It's always good to always display objectcount in your debug text. You'll see when you collect the first rocket the objectcount starts rising rapidly.

  • I am still very new to Construct 2 and need to learn a few things and tweaks. Thank you very much to both of you. I will try your suggestions. <img src="smileys/smiley1.gif" border="0" align="middle" />

    /Edit: OMG! I added objectcount and it creates about 1000 rocket objects for each one collected. I will try to fix this now. <img src="smileys/smiley3.gif" border="0" align="middle" />

    I added a global var to check if an HUD updated is needed (after collecting one it is set to 1)

    <img src="http://img3.fotos-hochladen.net/uploads/rockethudfixe512yluipj.jpg" border="0" />

    This seems to fix the huge amount of objects and the lag when you launch rockets. Thank you! <img src="smileys/smiley1.gif" border="0" align="middle" />

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