0 votes

Is there any way to make a sprite disappear by pressing buttons in correct order?
For example, there are 1~5 buttons and when you press button1, button2, and button3 in order a sprite disappears.

Godot version v3.2.3stable.official
in Engine by (28 points)

1 Answer

+1 vote

This is how I would do it .

  1. Have an array to hold the button presses in order. Nothing too complicated, just integers indicating button numbers. This should be global.
  2. Connect the pressed signal of each button to the same function while passing a custom varible carrying the button number.
  3. The function then adds the value of the custom varible to the array holding button presses.
  4. Declare another global array holding a sequence of button presses which should triger the hiding of the sprite. The sequence is just a list of numbers.
  5. This triggering array is compared with the first array in the function connected to the pressed signal of all buttons and if they match, I hide or queue free the sprite.

If this is the behavior you are trying to create but you have problems implementing it in code, comment below.

by (2,017 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.