Make button trigger only ONCE when held down?
Hey guys. so im currently working on a guitar hero style game, where you have to press a button according to what random actor is displayed on the screen. when the correct button is pressed, the random actor is destroyed and a new random actor takes its place. if you press the wrong button, you lose a life.
The problem im having is that if you hold down the correct button and the actor is destroyed, then it continues on to the next actor spawned. so for example if you destroy the green actor by holding down the green button, but continue to hold down the green button, when a red actor spawns, you will automatically lose a life, because the wrong button is being pressed. how do i make it so that i press the button, and when the next actor is spawned, i have to take my finger off the screen and re-press the button for it to register as a correct or incorrect move? Thanks
Comments
Hi @MarpCark it'll help for more detailed rules/behaviours in your buttons - but at a guess based on what you've said, you surely have used a boolean attribute similar to:
Then add:
Along those lines; (or if you've used an integer, change it back to zero); hope it helps.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
hi @gyroscope thanks for responding. yes those are almost the exact same rules that are currently in my game. I think the problem im having lies in the 'Actor receives event - Touch is pressed' rule. i think the problem will sort itself out if i code something similar to what is in platform games, like mario or crash bandicoot, where you press a button to jump, the actor jumps, and then when he hits to floor and you're still holding the button, he won't jump again until you release the button and press it again. do you know what i mean? i just can't figure out how to code something like that. thanks again for the response .
Take a look at this simple demo. I started to plan for a boolean condition but just left the Touch is Pressed condition and it only triggers when you release and then click/tap again.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
hi @tatiang @gyroscope thanks for helping fellas, but 3 cups of coffee and several screams into a pillow later I've finally cracked it, and have built a button that can only be pressed once before the player must release his screen and press the button again for the action to register.
i made a game.Attribute called ButtonOn (boolean) and another called Kill (boolean). then in the button actor i put:
When touch is pressed -
Timer ( For 0.1 sec) (run to completion checked) Change attribute - ButtonOn - true
Timer (After 0.1 sec) (run to completion checked) Change attribute - ButtonOn - false
in another rule:
when all:
game.spawntarget - true (the boolean that knows when there is a target on screen)
game.ButtonOn - true
Change Attribute - game.Kill - true
In Target actor:
When all:
game.Kill - true
Destroy
Again thank you kind sirs for responding to my post, no doubt ill be needing your help again in a few hours with another problem Cheers
I'm glad you got it working and appreciate that you shared your method with everyone but I'm also wondering if the demo I posted worked for your setup?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
yes, i used it, thank you, but i changed it a bit. instead of clicking the actor the destroy it, i used the method above to make a button that destroys it. there is a lot more code wrapped around this to create a guitar hero type game, including rules that have negative effects if you press the wrong button, (there are 5 buttons) press it at the wrong time, or don't press anything at all.
Hello, I am making a guitar hero inspired game.
The rule that I put was: If touch is pressed and its colliding with the "ball" then add points otherwise display the text game over.
On the actor this is the rule: If touch is pressed and its colliding with "Actor 1" then destroy actor
However this hasn't worked for me =(