How do I make click events work properly?

0 favourites
  • 11 posts
From the Asset Store
High quality sound effect pack, in the following categories: Simple, negative, pozitive
  • I am having no sporadic success getting click events to activate.

    For instance:

    This click event does not want to work, when I run it in Chrome. It will not do any of the actions listed in either event.

    I have tried with my toggle being global or local. I've tried conditioning it on the opacity of my "blotter" object.

    When I disable the ".. click on toggleText" event then everything works as intended, so why don't my click events work?

    I am sure I am doing something simple and stupid wrong... I just can't find it yet.

  • Hi gumshoe! I can't see your "for instance" but I had a similar problem that drove me nuts for a while - it just might be the same thing that's affecting you...

    Double click the object that you want to be clickable.

    When the "Edit image" window opens up, look down the left hand side and click on the bottom icon "Set collision polygon"

    Look at your image in the editor and make sure it is fully covered.

    If not, you can right-click for some automatic options or else drag and drop the little red squares.

    Hope that helps.

  • Let me see if I can upload the image to the Scirra site rather than a random image host site.

    Here is the not working copy:


    I found a toggle button tutorial that worked it a different way.

    This version seems to work. It is just an annoying side effect of JavaScript being completely asynchronous. It seems that both events (in the previous example) triggered simultaneously.


  • I've run into this problem a few times, I think basically both events are run at the same tick so the switch is turned on and off instantly. A quick solution is to add a wait action of 0.01 before changing the variable.

    It's also important to check the "Static" box for the local variable if you use local variables for this, otherwise the value is resetting every tick.

  • Just put an Else between them. Even better (IMO) is to make the variable an instance variable. What happens when you have 2 clickers?

  • Yeah, Else seems to work. Instead of the onOffToggle = 1 use and else condition.

  • Ok, cool. I will keep those two observations in mind when doing toggle switches in the future. I am definitely going to implement these, because I don't need any more global variables running amok in my MMO.

    I have had other click actions behave in peculiar manners since then also -- not just toggle buttons -- so there is definitely some clicky weirdness going on that I do not have a good handle on yet.

  • The Toggle-switch behaviour might be useful too.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The Toggle-switch behaviour might be useful too.

    Is that something that already exists? Or are you suggesting? I can't find this in the Behaviors?

  • > The Toggle-switch behaviour might be useful too.


    Is that something that already exists? Or are you suggesting? I can't find this in the Behaviors?

    It's 3rd party, look in the completed add-ons forum.

  • Alright, I'll look into it.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)