How to make other buttons' animation change when the current

Discussion and feedback on Construct 2

Post » Wed Jun 24, 2015 1:03 am

Hi,

I am trying to add animations on my buttons when touched to set them as "OT" animation, when untouched set to "default", everything is fine but the problem is when I leave the first button touched and go to touch the second one, the first button still animated, I would like to make other buttons to be the "default" animation when I touched anyone button, who have ideas, please help, thanks

File: https://www.dropbox.com/s/w5pkfskdlbg2reb/2.capx?dl=0

thanks
B
11
S
3
Posts: 172
Reputation: 1,178

Post » Wed Jun 24, 2015 2:45 am

The problem is you are never setting the "close" instance variable to false once it is set true by touching the button. So when you touch the second or third buttons, the other buttons still have "close" set to true, so they still play the OT animation.

I got it to work the way you wanted by adding a sub event under the Touch event to Pick All cityButton, then a sub event under that to select cityButtons playing the OT animation, then an action to set "close" to false. (then their animation gets set to "Default" by the code below.

With that change the code works fine, but you should be aware that every single tick it has to select all the buttons with close true and set their animation to OT, then select all the buttons with close false and set their animation to Default. That is a lot of extra work, 60 times a second with no visible difference to the user. With only a few buttons, you wont have a problem, but as the complexity of your game grows you may want to eliminate repetitive events that don't really do anything useful, and structure it in a way so that it only changes the animations once in response to user input.
B
94
S
33
G
20
Posts: 438
Reputation: 17,615

Post » Wed Jun 24, 2015 5:56 am

@AllanR thanks, problem solved like you said, really thanks
B
11
S
3
Posts: 172
Reputation: 1,178


Return to Construct 2 General

Who is online

Users browsing this forum: mrkaio and 3 guests