Spawn Without Using Every X Second

0 favourites
  • 12 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • So you have some idea of why I'm asking here is my original question which while I did get a lot of great responses I could get none of them to work.


    I was wondering (And I wouldn't ask if I didn't try everything I can think of because I really am trying to learn how to do this properly) but I'm leaning so I need to ask question right now so I hope you can help please.

    I have the spawns set at different Every Random X times. It starts off slow with just one and then another and then another so the longer you stay alive the more things are coming at you. (7 different random X spawn types) Yes, I am leaving the page on any hit of my hero or if he is pushed off the layout the game ends and takes you to option page to start again or go to the intro page.

    If I take a while getting back to the game as soon as I hit the start game button I get all the spawns at once because the Every Random X is still counting even if I'm not playing the game.

    In order to keep the gradual flow from easy in the beginning to harder the longer you play the Every Random X needs to start from 1 each the game is started. It's not doing that for me, once the game is started if it gets to 300 seconds when the harder enemies would appear after the first game if you want to play again you immediately start getting the harder spawns and many of them right away instead of starting slow abd then getting harder.

    I did go back and group everything and tried the deactivate group but that did not work. I tried the the Pause Plugin and while it worked pausing it does not reset the Every Random X count.

    The set time scale to "0" works fine but it's not resetting the Every Random X count.

    I've tried everything I just want when the game ends to stop the spawn count and when the game start and I mean actual game play for it to reset the spawn count (Every Random X) so it starts from 1 second not at whatever time the game has been running, but actual game play time.

    Is there a way to do that?


    Is there a way to spawn objects without using every X second and then I won't have to worry about turning it off when the player dies.


  • Every X seconds is bound to game time (as you've noticed), so if deactivate it and later on reactivate it, every 10 seconds could fire off directly in less than 1 second or it could take up to 10 seconds till it fires off.

    You have various options actually.

    You could use timers (which ofc you can stop and start anew when the game starts again).

    You could use cooldown variables.

    You could write the current time into a variable and then later on substract time-oldtime to find out how much time passed


    on new game start: set oldtime = time

    system compare - if time-oldtime > 5: spawn stuff, set oldtime = time

  • I could say Oh yeah thanks I will try that and pretend I know what you're talking about or I could be honest and say I kind of understand but not quite sure, and that would be the truth. I do appreciate it very much and thank you for taking the time to help.

    I will do some research on what you have said and see if I can figure it out.


  • I created a variable called Difficulty with an initial value of 0. Also created another variable called Stage initially this is set to 0. On the Title screen whenever they click the play button or hit enter to play we set the Stage 1 variable to 1 and goto layout Stage 1. We have an event that says For Every 1 Second with the condition that Stage variable is = 1 then we add 1 to Difficulty. If the player dies, Difficulty is reset to 0 and Stage is reset to 0 and we goto layout Title Screen. Then you can have your different types of enemies spawn off a Pick Random Instance of a Spawn sprite. Saying if Difficulty is greater than 0 and less than 25 then spawn Easy Enemies. If Difficulty is greater than or equal to 26 and less than 50 spawn mid enemies. So on and so forth.


    <img src="" border="0" />

    I hope this helps.

  • I used an array.

    check out my capx.

    post on the second page

    if you need another example for a cooldown system.

  • VictoryX and philx Thank you soooooooo much!!!!

    Ok! thank you for the visual I will get to work and let you know what I come up with.

    philx if and when you have the time yes I would like to learn all I can so cool downs would be nice to know as well...

    Thank you.

  • Ok, I think I'm following you... How do I group or tag the enemies so the random pick only picks from each difficulty group? Right now I have all my enemies grouped under "ENEMIES" when I pick a random spawn for the easy group, how do I tell it to only look at the easy group?

    I'm sure it's there I'm just not versed enough to fully understand it yet but it makes great since and I do appreciate it.

    Thank you

  • (or anyone who may know) I think I get it I have to do it for each enemy and I have 9. 3 easy, 3 mid and 3 hard. So let me ask you, can I group them separately and then have the random pick choose any from that group?

    Only one way to find out and that's to go try right?

    Thanks, this will be a good start.

    Thank you for your time and everyone who offered help thank you.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Can you send me the capx? I'm stuck at the PICK A RANDOM SPAWN. It's only allowing my to pick from the objects I have already.

    Yours is a black square and then it spawns is different object from your black square. I'm just not seeing those options to choose from.

    Sorry to be so difficult I just have everything almost finished at this stage and I want to get past this part.


    NEVER MIND I GOT IT!!!!! Just Make a Sprite Called SPAWN!!!!

  • This is exactly what I wanted and needed. Thank you for teaching me something new. Seeing it really helped me understand it better.

    This works well with my set up thank you and everyone.

    I can move on now...

  • Sweet, glad I could help! I would've uploaded the CAPX but I'm still new to the forums and Construct 2. So I wasn't sure if I could just put the CAPX file in my dropbox and give a download link, or if you needed all the files along with it.

  • VictoryX I'm good to go bro... That did the trick.

    Thanks again

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