How do I create an event for when 2 keys are down?

0 favourites
From the Asset Store
Piano Keys
$3.99 USD
A musical typing game where the goal is to play a song by pressing the matching keys as fast as you can!
  • First make sure that the Instance variable you have created is of the Text type.

    To set the Instance variable of the Player object, create an action, double click on the Player Sprite Object, double click on the Set value (under the Instance variables category), pick the Direction variable (that you had created before) from the list (it should be the only one existing) and on the Value field type the direction you want to set e.g. "Right" with the quotes.

    Do that for every direction, just like in my example.

    The same applies when you check the content of a variable (compare variable) in a condition. You type the corresponding direction with quotes (e.g. "Down") and Construct only triggers the down animation when the condition is true.

  • First make sure that the Instance variable you have created is of the Text type.

    To set the Instance variable of the Player object, create an action, double click on the Player Sprite Object, double click on the Set value (under the Instance variables category), pick the Direction variable (that you had created before) from the list (it should be the only one existing) and on the Value field type the direction you want to set e.g. "Right" with the quotes.

    Do that for every direction, just like in my example.

    The same applies when you check the content of a variable (compare variable) in a condition. You type the corresponding direction with quotes (e.g. "Down") and Construct only triggers the down animation when the condition is true.

    Great! I managed to set the directions accordingly (I had forgotten about the quotes, silly me!). Only one more thing, and I'll be on my way. What did you do with events 15 to 19? I see you managed to link 4 different events to event #15, and I don't know how to do that. I reckon that's a very useful thing to do and I would like to know what you pressed in order to do that.

  • These events are called sub-events. There are many ways to create them. I use the "B" shortcut that creates an empty sub-event. The "S" opens the Add event dialog, so you can immediately choose a condition. Finally, if you right click on the furthest left side of a condition (just right before the icon of the object that the condition checks), a menu appear that has many important choices, the first of all being the "add" in which you will find the sub-event options.

    And yes, this is a very useful thing, not only it saves you space (because you can nest many sub-conditions that have a common condition on top and those conditions can nest sub-events by them self etc), but since they act hierarchically, you can create complex events that pass along actions from the parent conditions to the child conditions whenever the parent is true. This has the added bonus of being very efficient, since when a top condition isn't true, all sub-events are ignored and C2's code is being read faster per tick.

  • These events are called sub-events. There are many ways to create them. I use the "B" shortcut that creates an empty sub-event. The "S" opens the Add event dialog, so you can immediately choose a condition. Finally, if you right click on the furthest left side of a condition (just right before the icon of the object that the condition checks), a menu appear that has many important choices, the first of all being the "add" in which you will find the sub-event options.

    And yes, this is a very useful thing, not only it saves you space (because you can nest many sub-conditions that have a common condition on top and those conditions can nest sub-events by them self etc), but since they act hierarchically, you can create complex events that pass along actions from the parent conditions to the child conditions whenever the parent is true. This has the added bonus of being very efficient, since when a top condition isn't true, all sub-events are ignored and C2's code is being read faster per tick.

    Aaaaand everything works as intended! Thank you so much!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You are welcome!

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