[SOLVED] How do I execute a command for X time

  • Hello there everyone! Just acquired this marvelous program and I'm trying to get started...

    I've been searching around the forum for a way of executing a command for X time and the only thing i've found is something related to "ignore input" but that doesn't serve me...

    What I need is something like this:

    If CONDITION

    Execute ANYACTION for X seconds

    Command can be anything from user input to move object towards position, etc...

    Is there a way anyone could help me?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could use the Wait action.

    If CONDITION

    -> Toggle Boolean/variable

    -> Wait x seconds

    -> Toggle Boolean/variable back to original

    That way you will be able to use the variable to execute an action for a set amount of seconds.

  • Well thanks for your reply! :) Wohoo!

  • Is there a cleaner way to do this? For i to 100 etc?

    For example:

    I have an image which I wish to rotate, However, the built-in rotate function only rotates along the exact center of the image, regardless of where my image point is set. (-200,0 for the sake of argument)

    So when I try to rotate manually, what I end up with is:

    System / Every Five Seconds

         IMAGE rotate 20 degrees clockwise

         system / wait 0.2 seconds

         IMAGE rotate 20 degrees clockwise

         system / wait 0.2 seconds

         IMAGE rotate 20 degrees clockwise

            etc.

    This makes the 60 degrees of rotation I was looking for, but it breaks it up into 3 movements. In order to get a fine animation, I would have to break it up further, rotating the image 10 degrees every 0.1 seconds. This would have six ticks, which is still not that great, especially since it would require six more lines of information.

    With BASIC, you could run a FOR i to 1 loop... But how on earth would you do it here? I know there's a for loop available here, but I can't make it work.

  • I guess this should be done easily with a System -> Compare Time condition.

  • KFC thanks, I get it now.

    Same example as above- a simple rotating slide effect...

    STEP ONE:

    Begin by making a global variable. (Mine is SLIDECOUNT, set to 0.)

    STEP TWO:

    Set up the time frame that you wish your slide to rotate. I want my frame to last for 3 seconds, then rotate clockwise for the duration of 1 second.

    System / Every 3 seconds

         ADD 1 to SLIDECOUNT

         System WAIT 1 Second

         SUBTRACT 1 from SLIDECOUNT

    This Action simply causes the SLIDECOUNT variable to change from 0 to 1 for 1 second every three seconds.

    STEP THREE:

    Now we just have to tell the system what to do during the one second that SLIDECOUNT is going to be equal to 1. We can do that using the System / Compare Variable option.

    System / SLIDECOUNT = 1

         SLIDECOUNT / Rotate Clockwise 1?.

    And that's it.

    When you run that, the system will wait for three seconds, start rotating your slide by 1?, and for the the duration of SLIDECOUNT=1, it will just keep rotating by a single degree.

    Lol... I was making it waaaaay harder than it needed to be.

    Nothing against the seasoned vets, but...

    You could use the Wait action.

    If CONDITION

    -> Toggle Boolean/variable

    -> Wait x seconds

    -> Toggle Boolean/variable back to original

    That way you will be able to use the variable to execute an action for a set amount of seconds.

    ... sometimes the psuedocode can be a bit vague. Structuring things closer to syntax really helps. I never would have imagined that it would have required multiple actions to achieve this particular task from KFC's psuedocode, which is grouped together like a paragraph, and leads one to believe that it could all be placed in one Action.

    I'm not complaining, just trying to explain why it seems like we're asking the same question five times! ^__^

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