How do I make this locked doors open

0 favourites
  • 7 posts
From the Asset Store
10 Orchestral Soundtracks / ~2 mins each / 11 audio clips in total
  • Hi, i want to make the locked door open 1 by 1 when the player push the right button.

    Here's the example

    There's a 1 sprite named locked door (red blue green) and each button to open the door with the same color

    When player steps on the first one (red button), the red door opens

    When player steps on the second one (blue button), the blue door opens

    When player steps on the third one (green button), the green door opens

    But when the player didn't push the button in the right order, the door will be locked again (red blue green)

  • Track the colour of the last-pressed switch by adding a variable to the player. A string-variable would work for this - we'll call it Player.LastButtonColour. You'll need another variable on the button to track what colour should have been pressed previous to it in the sequence - we'll call it Button.PreviousSequenceColour

    When the player jumps on a button, check the Player.LastButtonColour against Button.PreviousSequenceColour. If they match, open the matching door, and set Player.LastButtonColour to represent the button's colour. If they don't match, re-lock all doors in the sequence.

  • Track the colour of the last-pressed switch by adding a variable to the player. A string-variable would work for this - we'll call it Player.LastButtonColour. You'll need another variable on the button to track what colour should have been pressed previous to it in the sequence - we'll call it Button.PreviousSequenceColour

    When the player jumps on a button, check the Player.LastButtonColour against Button.PreviousSequenceColour. If they match, open the matching door, and set Player.LastButtonColour to represent the button's colour. If they don't match, re-lock all doors in the sequence.

    A string-variable? That's new to me. Can you create a .capx of how this would work?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Track the colour of the last-pressed switch by adding a variable to the player. A string-variable would work for this - we'll call it Player.LastButtonColour. You'll need another variable on the button to track what colour should have been pressed previous to it in the sequence - we'll call it Button.PreviousSequenceColour

    When the player jumps on a button, check the Player.LastButtonColour against Button.PreviousSequenceColour. If they match, open the matching door, and set Player.LastButtonColour to represent the button's colour. If they don't match, re-lock all doors in the sequence.

    Ahh, i get it.

    Thanks man!

  • A string-variable? That's new to me.

    Objects can carry variables, which must be either number (float or integer), string (alphanumeric), or boolean (true/false) values according to a preset specified by the developer:

    https://www.scirra.com/manual/73/instance-variables

  • Thanks man!

    No worries, hope it works out

  • So... it's just an instance variable. OK.

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