How do I make a code thing

0 favourites
  • 9 posts
From the Asset Store
Two levels with two sistem Wave. with Source-code (.c3p) + HTML5 Exported.
  • Alright, so let's say i'm making a horror game and you have to enter a code to go through a door.. the code would be "325" if you enter it in order the door opens, if not nothing happens

    what i want is how do i control the order of the number, like if i entered "523" nothing happens or so.

    i didn't know how to explain this very well but i think you got my point.

  • This is a way to do it

  • Have a text object called dc_xxxxx_input or something you think makes sense for easy code readability. Also make a form button that matches whatever naming scheme you're using but _button at the end. Then use the following Event code:

    dc_input_xxxxx_btn -> On clicked

    Then add a sub-event of:

    dc_xxxxx_input -> Compare text

    Set the compare value to be "325".

    Then, add the success events you want to happen. Also add an Else for if it fails and you have fail events. If you wanted to keep track of the correct codes, such as if the player can discover the code, it should be in a text instance variable for the dc_input_xxxxx_btn, and instead of doing the dc_xxxxx_input -> Compare text, you want to instead do:

    dc_input_xxxxx_btn -> Compare instance variable

    Then check if dc_input_xxxxx_btn is equal to dc_xxxxx_input.Text, then have success and fail events.

  • Thank you both, this was easier than i thought :D

    Any idea how to do it with sprites or buttons?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Can you be more specific?

  • Well nvm, i figured it out.. here's the capx it may help anyone..


  • You don't need that spriteFont to clear the textbox all you do is this. I have made change to your work

  • Ok I get what you mean now.

    I've upgraded your capx a bit. I've added an OK btn for imputing the password (no need of pressing Enter in the keyboard), and now the system uses only one SpriteFont for the numbered Btns and another one for the ok/clear Btns (you can merge those categories into one universal Btn if you wish).

    And, finally, there is a mouse cursor change when ever you are hovering on top of a Btn.

  • Cool stuff,thanks guys!

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