How to implement double clicking
cosmopolice
Member Posts: 3
Hello,
my apologies if that has been covered already but the search engine turns nothing of interest.
I'm basically wondering how I should go about implementing a double click feature. Basically the idea is to have movement occur only if 2 clicks are performed within a certain time frame, else something else occurs.
For the life of me I've tried with timers, indented rules and what have you. I'm just not sure I understand how to inquire on the mouse button status properly to implement this feature... Help welcomed!
cosmo
my apologies if that has been covered already but the search engine turns nothing of interest.
I'm basically wondering how I should go about implementing a double click feature. Basically the idea is to have movement occur only if 2 clicks are performed within a certain time frame, else something else occurs.
For the life of me I've tried with timers, indented rules and what have you. I'm just not sure I understand how to inquire on the mouse button status properly to implement this feature... Help welcomed!
cosmo
Comments
Create an actor to be clicked
set up rule:
when mouse button is down change attribute Clicks to Clicks +1
When Clicks are = 2 (DO WHATEVER)
and set attribute Clicks to 0 (to reset it, so it can be used again)
Need Help? Email Me | Templates | Full Game Source Code
I had pretty much tried that however : the issue is that doesn't cover a time frame requirement between clicks. You could pretty much click with 10 minutes apart and have the second click trigger the event.
My issue has more to do with the time frame and the fact that when used in a timer the 'Mouse button is down' condition is met even with a single click. (for instance if you create an every 0 seconds timer with the implementation you suggest, the 2 clicks would be reached with a single click has it is too hard to release the mouse button quickly enough.
So far my best idea was to have an every second timer work in conjunction with a counter that 'counted upwards' the amount of time the mouse button is down, then a test is performed through a rule checking if 'click-on.time' is inferior to T (constant integer representing a threshold where by if click-on.time is inferior to 25 or so, it suggest the button was released during the time frame.) It doesn't quite get me where I want to go though. I'm pretty sure I'm missing part of that puzzle...
Thanks
Edit : after fine tuning the approach mentioned above I'm getting better results although it is still not very reliable. But it is working sometimes so I might be on the right track. The main issue I have remaining is that when the two clicks are two close to one another they don't seem to register properly and so my conditions for the wanted behavior isn't reached...
Also- test it out on your device to make sure its not the GameSalad Viewer's lag. to do that change the mouse down rule to touch pressed.
http://cl.ly/1g0l3N1p2q0W
Need Help? Email Me | Templates | Full Game Source Code
Then create a rule that says, if click count >= 1 Then after 0.3 seconds change attribute click count to 0.
Then you just have to make the rule for what happens when the click count is >= 2
I'm using this in my current app, and it works amazing. A great feature is that even if you keep tapping over and over, the rule can only get activated every 0.3 seconds, and also if you only click once, after the 0.3 seconds the click count is reset, so it works in a very natural way.
Need Help? Email Me | Templates | Full Game Source Code
I am making a game in college and a part of my game you have to click an enemy 10 times to destroy it. I have tried some of your tips but it still destroys after the first click. I have an attribute for killing the enemy on a certain amount of clicks but it doesn't seem to work
Make an Attribute called Clicks (or whatever)
Each time your enemy is clicked add 1 to Clicks.
In your actor have a rule that says:
if Clicks is >= 10, Destroy the actor.
That is really all there is to it, hope it helps!
If you want to post an image of your current rules I could take a look at those too.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page