How to implement double clicking

cosmopolicecosmopolice Member Posts: 3
edited October 2012 in Working with GS (Mac)
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

Comments

  • bjandthekatzbjandthekatz Orlando, FlMember Posts: 1,375
    edited October 2012
    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
    Create an attribute called Clicks
    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)
  • cosmopolicecosmopolice Member Posts: 3
    edited October 2012
    Hi, thank you for the quick response.
    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...
  • bjandthekatzbjandthekatz Orlando, FlMember Posts: 1,375
    heres a template i just made, let me know how it works..

    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
  • entersimonentersimon Member, PRO Posts: 273
    edited October 2012
    create a click count attribute (either self or global, depends on how you are going to use it) that adds 1 to itself each time the actor is pressed.

    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.
  • bjandthekatzbjandthekatz Orlando, FlMember Posts: 1,375
    create a click count attribute (either self or global, depends on how you are going to use it) that adds 1 to itself each time the actor is pressed.

    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.
    i just set up a template for that above. i tried it with .3, .4, .5 and they are all to laggy for the GameSalad Viewer. you would have to test it out on an actual device first.
  • DesignsByJamesDesignsByJames Member Posts: 4
    I know this is quite an old post but I really need assistance with a similar issue.

    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
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    edited November 2013
    Hi James, it's pretty much spelled out above but let me break it down again just in-case it helps.

    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.
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
Sign In or Register to comment.