On Object Clicked firing more than once

0 favourites
  • 8 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • I'm a little confused over the intended behaviour of the situation below.

    I have a sprite with 3 animations. On the condition "On Object Clicked" I set the animation to the second state. The strange thing is that then the event directly below it also fires.

    <img src="http://i.imgur.com/bkOis.png" border="0">

    Sample Capx

    Now I understand that because of the green arrows these events will fire immediately, plus I understand the order the scripting language runs in (top to bottom). What I would have expected though is that the second event should fail because I've not clicked on the second animation yet - the mouse button is still down, I've not released it. If these were "on mouse down" conditions I could understand, but they are on mouse click and I've only clicked once. I only expect the event to fire once because of this.

    Should this be working or am I thinking about this the wrong way?

  • This is almost similar to another case in here:


    A trigger is called on an object that is "newly created" on the same frame when the click happens.

    I thought this is kinda weird too,

    but I guess when you read above thread the conclusion is, don't depend on this kind of behaviour.

  • put an "else" between them ;)

    [ Left button clicked on sprite
    • if animation 1
    • else if animation 2
    • else if animation 3


  • Yeah that's the way it works. You might think it should check the condition alongside the mouse trigger at the moment you click; but it just checks for mouse clicks and then goes through each mouse click event one at a time checking the other conditions. So whether a later event runs depends on what happens in a previous event.

    What you have there is the equivalent of:

    <img src="https://dl.dropbox.com/u/8367729/construct/pics/onclicked1.png" border="0" />

    And the solution like superkew says is:

    <img src="https://dl.dropbox.com/u/8367729/construct/pics/onclicked2.png" border="0" />

  • I'll try setting up the else statements and see how that goes.

    I have to agree with the thread that Potato linked to, R102 made more sense.

    I understand that, as far as the tick is concerned, animation state two has been set and the mouse has been clicked. But it should be able to determine that I didn't click on animation two, I clicked on animation one. As far as I can tell that is incorrect to register me clicking on animation state two.

    It might be hard to solve this behind the scenes, but I'm edging from 70% convinced to 98% convinced that this is a bug <img src="smileys/smiley1.gif" border="0" align="middle" />

  • boolean - no, this is not a bug. Let me explain the interpretation of the logic that you did by Construct 2. In the same tick, the object was clicked. The first event states the condition "object clicked"(true) and "StateOne"(true), set animation to "StateTwo". So animation is now at "StateTwo" but the processing of the logic in the tick is not over yet. The next event, "Object Clicked"(true because it is still in the same tick and the condition is true in this tick) and "StateTwo"(true because the above event set it so), hence, it also runs. So on and so forth. I hope you understand what you just did.

  • Ahhh, I see. So the condition is saying the object was clicked, and now as the next condition rolls up and the animation has been set, so it's true. Mmm, I guess that does make sense.

    Confusing, but you are correct <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I had a problem with this when making a toggled option button. Both had the green arrow event for on clicked with secondary condition for if it was off an on.

    I solved this problem by adding a wait of 0.1 seconds. That way it would't cycle between the valid options instantly all in the single mouse click. It would wait before considering other variables.

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