Problem with mouse clicking on an object

This forum is currently in read-only mode.
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • Well... after removing pretty much EVERYTHING from this rather annoying cap file... I've still got problems. Trying to add 1 to my global variable damage and remove 18 from the global variable Gold. But it multiplies everything by 3. Earlier I was having lag and it would only remove the requested amount if I moved the mouse quickly away after clicking on the button. But only on the first time, after that it would remove 3x the amount again.

    But anyways... here's the cap file. Any solutions or work arounds or pointing out whatever stupid mistake I've made would be way appreciated. I think I've spent a good 5 hours trying to figure out different ways to do this... without any luck. I've even tried at one point writing it in python, with the exact same result.

    http://dl.dropbox.com/u/6493733/MouseCrazy.cap

    Thanks again!

  • I used to always get this problem, even though I knew how to fix it. I would quickly make something and forget that I needed to add logic checks.

    Anyways, I think what is happening is that when you click, it's registering three times.

    I messed around with your .cap and set it up like so:

    add a private variable on the shop button called 'clicked' or something similar. default is 0

    On Click/Double Click and ShopButton's clicked variable is 0 and Gold >= 18

    do your gold subtraction, etc here

    set clicked to 1

    then to reset the button...

    On Mouse Button Released and ShopButton's clicked variable is 1

    set clicked to 0

    Once I did that, it worked.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Mmmm, that's about what we ended up doing. Odd that it is needed though.

  • There are three instances of the "MouseKeyboad" object. Use the expression "Python("len(MouseKeyboard)")" to see that it's true (it returns 3). The solution is to create a new "MouseKeyboard" object, change all the "MouseKeyboard" events to use the new object and then delete the old object.

    Solution in steps:

    1

      In the Layout editor insert a new Mouse and keyboard object. It's name will default to "MouseKeyboard2".

    2

      Go ahead and make it global, (not really necessary, but it's a good idea).

    3

      Go to the events and for every mouse and keyboard event: double click, hit back twice, select "MouseKeyboard2", click next twice and click finish.

    4

      Now go back to the layout editor, select the old mouse & keyboard object "MouseKeyboard" and hit the delete key.

    5

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