trouble spawning enemy

  • Hi I'm working on a commercial IOS game. But there seems to be a blank pause at the spawning of my enemy.

    for example:

    system    every 3 sec |   system     set enemygen to int(random(3))

    system    enemygen=0|   system     create object blue on layer 1

    system    trigger once

    system    enemygen=1|   system     create object red on layer 1

    system    trigger once

    system    enemygen=2|   system     create object green on layer 1

    system    trigger once

    i figured out that the blank pause is caused by the number generator when it generates the same number. I wanna keep the trigger once condition because I don't want to overspam , limited to one enemy per 3 second.

    so how do i fix this? <img src="smileys/smiley5.gif" border="0" align="middle" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi there, first of all, shouldn't you be using "enemygen=1,2,3" instead of "0,1,2"? maybe I'm wrong, if it works as it is, then it's all right, I'm kind of a n00b here :P

    My approach would be to have a number variable with kind of a "cooldown" effect instead of the "trigger once" condition, for example, I would set a "cooldown" variable to... I dunno... 500, and have an new event with "every tick" substracting 1 from that variable. Then have:

    system    enemygen=1

    system    compare variable: "if cooldown = 0"

    That's one idea... maybe it'll come in handy. Hope it helps :P

    EDIT:

    Another idea, you could put a "wait 3 seconds" after every enemy spawning :) I think that could work too... you could give it a try.

  • lol thanks! the cooldown idea is something i didn't think of! I used the 3 second instead when i was tinkering around =)

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