how to make a button unclickable?

Get help using Construct 2

Post » Sun Aug 19, 2012 12:59 am

[QUOTE=Yann] use the same object and put the graphics of "on" and "off" state in frame 0 and 1
on click on button -> set frame to 1-self.frame

Great suggestion.   I added a second frame to my on button graphic with the off button graphic. So now it has two frames.

   on click on onButton -> set frame to 1-self.frame

says "frame is not an expression or instance variable in onButton"

so I tried this:
on click on onButton -> set frame to 1-self.AnimationFrame

But now when I launch my game, it imedialtly jumps to the second frame, even though I havent clicked on anything, and the "initial frame" is set to 0.

Is this normal? how do I stop it animating and runing through the frames on its own?

I tried resetting the frame to 0 in the "on loading finished" and in the "on end of layout", but it still comes up showing frame 1 after the game has loaded for the first time. After thay, your frame toggle works fine.

Any ideas?

nutmix2012-08-19 01:07:17
Posts: 370
Reputation: 3,942

Post » Sun Aug 19, 2012 1:01 am

But now I get the weirdest of behaviour: the newly swapped in button also gets clicked event!

So I click once on an object, and in the onclick event for that object, swap the objects X&Y with a completely differetn object, and the new object also gets an onclick event, even though there has been no click on the second object.

Is this a bug do you think?
Nah, it's just that when you click the mouse it will go through all the click events on the event sheet. It checks event 1, sees you've clicked on button 1 and then hides that button and moves button 2 into place. Then it checks event 2 and now button 2 is below the mouse so it counts as a click on it, even though it wasn't there when you first clicked.

This came up before when someone wanted to show a box by clicking a button and then hide it by clicking on the box. The solution was to toggle a variable with the mouse clicks and then toggle the objects visibility based on the variable. You have to seperate it so the mouse clicks don't interfere with each other.

toggleMenu.capx (r99)

Yann's method is better for a toggle button.
Posts: 1,520
Reputation: 25,285

Post » Sun Aug 19, 2012 1:03 am

If you edit the animations, is the animation speed 0? This will stop it from animating.
It's so simple, but it something I forget to do more often than you would think! Haha...
Posts: 96
Reputation: 2,680

Post » Mon Sep 07, 2015 4:50 pm

I had the same problem as you. I have tried booleans, tried moving my buttons, tried even destroying it and creating it only when my popup was appearing... nothing worked!. I have found the 100% perfect solution that works perfectly(at least for me, who tried and tried and tried, worked):

-Create a global variable called "time_until_popup_showed". It´s innitial value is -1.
-When the popup should open(or a layer should be made visible), make the value of this global variable be 0.
-In all conditions that have something to do with the button/image/object you dont want to be touched unless the popup is appearing, put the condition: "time_until_popup_showed > 0"
-Make an event that is triggered every 1 second and time_until_popup_showed > -1 to make the global variable be added by 1(time_until_popup_showed will be time_until_popup_showed + 1)
- If you made the user click somewhere (a button maybe) to open the popup/new layer, make this button invisible when you touch it(to make the popup open) and add this condition to its touch: button is visible
- when you want to make the popup disappear, don´t forget to set the time_until_popup_showed to -1 and the button cited above(the one that opens the popup) to visible
Posts: 27
Reputation: 275


Return to How do I....?

Who is online

Users browsing this forum: nanogod and 10 guests