Problem with mouse clicking on an object

For questions about using Classic.

Post » Mon May 24, 2010 3:05 pm

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!
B
2
G
2
Posts: 10
Reputation: 670

Post » Mon May 24, 2010 4:30 pm

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.
B
3
S
1
G
4
Posts: 37
Reputation: 1,299

Post » Mon May 24, 2010 5:21 pm

Mmmm, that's about what we ended up doing. Odd that it is needed though.
B
2
G
2
Posts: 10
Reputation: 670

Post » Mon May 24, 2010 6:48 pm

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[list:rr4f2ok0]In the Layout editor insert a new Mouse and keyboard object. It's name will default to "MouseKeyboard2".[/list:u:rr4f2ok0]
2[list:rr4f2ok0]Go ahead and make it global, (not really necessary, but it's a good idea).[/list:u:rr4f2ok0]
3[list:rr4f2ok0]Go to the events and for every mouse and keyboard event: double click, hit back twice, select "MouseKeyboard2", click next twice and click finish.[/list:u:rr4f2ok0]
4[list:rr4f2ok0]Now go back to the layout editor, select the old mouse & keyboard object "MouseKeyboard" and hit the delete key.[/list:u:rr4f2ok0]
5[list:rr4f2ok0]Problem solved. :D[/list:u:rr4f2ok0]
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest