How do I cancel a Wait Loop?

0 favourites
  • 12 posts
From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies.
  • Hi Everyone!

    So i'm working on a little Game and here's the situation:

    I'm having a Variable that if turned on initiates a Wait Action of three Seconds. If the three Seconds are up, another Action should happen but if the Player reacts DURING the three Seconds, again, another Action will happen.

    I kinda got it working with Subevents, but the Problem is, when i take the Action, the Game will still wait until the three Seconds are up to change my Animation Frame etc.

    Maybe to make things clearer: the Game is about a Guy trying to sleep but being tormented by a Mosquito. You only hear it in the Dark and if it sits on your Nose and you don't react quickly enough, you get stung. So the player has to turn on the Light in Time Everything works great so far, except the Timing bit, where you have to turn on the Light during the short Timeframe that the Insect is on Contact with you.

    So the Event basically sais: if the Mosquito Variable is onNose, the System is to Wait for three Seconds. If the Player switches the Light "On", the winning Animation is played and the Layout restarts. If the Player doesn't react, the losing Frame is set and the Night Layer is disabled and the Lightswitch is turned on. You then see the Losing frame for three Seconds and the Layout restarts... Hope that makes kinda Sense :S

    Thanks for your help

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Instead of the wait action it might be better to use the timer behaviour.

    For example - give the bed the timer behaviour.

    onNose =1

    trigger once

    bed - start timer Nose

    bed - on timer nose

    play losing frame

    onNose = 1

    Light = "On"

    bed - stop timer

    Win!

  • There is also the wait for signal, but in this particular case I don't think it's easier to implement.

  • Thank you! I wasn't familiar with Timers yet. I'll go over the books again but i'm sure it'll work out

  • Hm, weird. I think i did everything correctly and the Light On works great now but after the three Seconds expire nothing happens... I tried around with taking out the "Trigger Once" Condition but it doesnt seem to make a difference...

    Any Ideas?

  • having these events as subevents of a trigger once event won't work.

    I would make the trigger once - a subevent and have the start timer action on that subevent.

    Than making the on timer a separate event should be enough.

  • I think i'm too stupid... I tried every possible Combination including the one you told me but it still won't work...

    Sometimes its kinda confusing for me to know when to use Subevents and when to use normal Events. Another little Bug i encountered is, that my Mosquito Trigger Spawnsnew Sprites everytime i turn on the Light. When i set another Condition for either a Variable or that the Mosquito must be OffScreen it doesn't work either...

    It's pretty hard to explain so i also attached my capx File if anyone cares to take a look at it. Sorry for the crappy Graphics, i'm only prototyping

    https://drive.google.com/file/d/0Bwu0b_8ZTavBdlNYcFcxQXNPMmM/view?usp=sharing

    And here's my complete Event Sheet...

    As well as how this whole thing looks... The red Stripe on the right is the Trigger that makes the Mosquito sit on the Nose. The Timer only started working after i put it under the "On Collision" Event with this Trigger which maybe makes sense though...

  • If noone beats me to it I'll look into it later tonight..

  • I just found the Error and i'm officially an Idiot haha.

    I set the On Nose Variable as an Instance on the Mosquito... Which is of course pointless if i'm destroying it duh... Now i set the Variable as a Global again and it works

    THANKS!!!!!

  • Okaaay i'm back again. The basic functionality works although i'm having a new Problem with the Spawning of the Mosquito.

    I included a Wait Random Conditionq that should only happen when the Light is off, which works. If i switch the Light on and off multiple times though before the Object has been spawned, i get a whole Army of Mosquitos flying.... I only want this to happen ONCE and never have more than one Mosquito going on...

    I updated the Capx File too... I think i'm at the End of my Knowledge here, maybe there's a better way to do this :S

    Any help is greatly appreciated!!!

    https://drive.google.com/file/d/0Bwu0b_ ... sp=sharing

  • Every time the light goes of the wait the event is triggered one time.

    If the wait time hasn't passed yet MosqOn is still 0, so all actions will be executed.

    Dragging the action system set MosqOn=1 above the wait action will prevent this.

    Construct reads events and actions from top to bottom, so the order in which they are placed can be very important.

  • Thanks a ton! It seems i have the right ideas but kinda get the orders wrong quite often... i'll pay attention to that a bit more Thanks again!

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