How do I make the same button perform events sequentially?

  • I'm trying to get my controller to perform a series of steps sequentially (move around to select __________, press X, perform the next selection, press X, etc).

    Basically I'm trying to make a menu that does the following:

    Step 1 - Select element in group of objects by pressing up or down. Move on by pressing X.

    Step 2 - Select second element in group of objects by pressing up or down. Move on by pressing X.

    and so on until all elements are selected.

    The problem is that after step 1, when i press X all 5 steps are selected instantaneously. For consistency i want to make it so that X is the button the player presses to move on, and I've tried several avenues to solve this problem, but they all seem to fall flat. I also figured this would be an easily solvable problem, but for some reason (maybe the wording of my searches) I'm having trouble finding the solution.

    Does anyone know how to solve this issue?

  • Simple and fast way to do that would be to add a global variable that will save current state.

    on pressing X - add 1 to "state" variable

    Then you will only need to set "states" for the selections

    state = 0 - > Select element in group of objects by pressing up or down

    state = 1 -> Select second element in group of objects by pressing up or down

    state = 3 -> etc

  • Ok thank you I will try this

  • Or you can do it using groups instead of variables.

    Group 0, Group 1, Group 2...etc (any name will work). and then after pressing X simply deactivate/activate groups with events you want to run.

  • Tried the first suggestion, its doing the same thing (instantly at the last group from pressing x button)

    Going to try the second suggestion.

  • Can you post a file or at least screenshot of your events?

    This is actually quite easy to do, so I guess you might be doing something wrong.

  • Very crude example.

    Everytime when you press key "X" it will switch the state and same time make Sprite do different things (only once)

  • *Facepalm* I dont have the *trigger once* element in there. Ugh!

    Edit*: I used it before, but it didnt work when i used it before so i messed up somewhere

  • Ok I used it, and i'm thinking that its the way i arranged things that is messing everything up.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok, i now know the problem. Unless I put the "Trigger once" under the pressing of the button, it registers as me continuously pressing it, causing the count to go up to 20+ in one button press. O.O

  • That sounds about right. Pressing the button down means that is active and releasing it counts as inactive but the delay between up and down - no matter how short it feels, may take few to dozens of ticks. Using Trigger once always makes sure that event will run only once - no matter how long you press the button in that case.

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