I was wondering?
I'm making buttons for my game Up, Down, Left, & Right but I only want one of them to work at one at a time (due to animation interruption problems) . So if the player is pressing the Up button I don't want the down, left, & right buttons to work. & If the player is pressing the Down button I don't want up,left & right to work. I want this to happen with all the keys (for the left & right button also) . I want if you press any of those four buttons I want the rest to be immobilized.
I made four actors, so there was an Up actor, Down actor, Left actor & Right actor.
I also made four different Boolean Up, Down, Left & Right all set to false.
Then in put this in all the actors
Example:
1. When touch is pressed
2. do:
3. Change attribute game.up to true
4. otherwise:
5. Change attribute to game.up to false
(I did that for all the four actors just change the game.up)
Then in my main actor I said:
- Rule
- Touch is pressed
- Game. Up is true
- Game.Down is false
- Game.Left is false
- Game.Right
- Do:
- Move 90 at a speed of 75
- Animation
I did that for the rest of them according to the movement.
Then when I press the Up button it doesn't move or the Down, Left & Right buttons are still active when I told them not to be when a button is being pressed. I've been fooling around with this for about 3 hours now. Is there a better where to achieve what I want?
Comments
Try something like this (attached).
This may not be exactly like yours is set up, I whipped it up quickly, but hopefully you can pick it apart the stuff you need.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
@Braydon_SFX why are the are those 2 words on top of each other? & well when I press U or D it like trys to count up but it gets set back to 0. Is that what you intended?
Use a boolean to switch all the direction rules on and off. When a player taps a button/key it switches it off so none of them will work. Create a new rule in your actor which switches it back on when the actors stops moving i.e. your animation finishes.
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
I would suggest the rule to be as such (example for up button):
>
>
>
>> Change Image to: up_greyed_out.png
>
>Otherwise:
>
>> Change Image to: up_color.png
>
> .
>
>> RULE:
>>
>> When ALL conditions are valid:
>>
>* touch is pressed
>>
>>> Change attribute (game.Up) to: true
>>
>> Otherwise:
>>
>>> Change attribute (game.Up) to: false
Braydon is showing you a method of ensuring only one button is active at a time. When you press U or D it will do two things - record the direction that was pressed (the number after the text that says "Direction") and increase the number of "Active" buttons (the top text, that says "Active") to 1. When "Active" is 1, no other button can be pressed. When no buttons are being pressed (are "active") the number goes back down to 0.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Yeah, what he said. ; )
The letter "U" was to attempt ( which seemed to fail) to show which button was "Up" - "D" is for "Down."
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx