[Solved]For each and Trigger Once looping

  • I get a headache on this. They seems don't like each other and it keeping spawning of objects.

    <img src="https://dl.dropbox.com/u/1396615/bugImage/ForEachTriggerOnce.jpg" border="0" />

  • Do you want to stop the loop as soon as one spawning event has occured ? If so, remove the "Trigger once" and add a "Stop loop" action.

  • Magistross, I tried the way you said, not working:(

  • Hmmm, I think I misunderstood what you wanted. You want your whole loop to trigger only once. When do you want it to fire, on the start of the layout ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hm i have a similar kind of event in my isometric Z-ordering example. I have tiles that each spawn a certain number of objects on top of themselves to stack blocks up. I got it to stop spawning using a trigger once event.

    Its for a different purpose but this might help:

    example capx

  • Thanks for helping:)

    Magistross: My goal is trigger this event ONCE(1 loop for each) at anytime when the condition matches.

    Tommyttk: I find in your example the "Trigger Once" is in front of "For Each", which is the magic make it works! but It is only trigger once in the whole game/layout. What if I want re-trigger this when the condition matches?

  • I find in your example the "Trigger Once" is in front of "For Each", which is the magic make it works! but It is only trigger once in the whole game/layout. What if I want re-trigger this when the condition matches?

    You'll need to put it under event that is the condition you mention there. Generic method would be:

    global variable RUN_LOOP = 0

    RUN_LOOP = 1

    ..your loop here

    ... your loop action stuff

    .. RUN_LOOP = 0

    Now, whenever you wish to run that loop you can set RUN_LOOP to 1 in your events. That's the generic way, better way is making your loop a function. :)

  • Thanks for the hint! I eventually find the way:) It's basically same as Vee41 said, but since I have a lot of instances, so instead of global variable. I use instance variable and it finally worked!

    Here is the working example:

    <img src="https://dl.dropbox.com/u/1396615/bugImage/dynamicSpawn.jpg" border="0" />

    Thanks again:)

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