How do I detect simultaneous touch of 2 objects for iOS?

John Craig john at splash21.com
Sun Oct 2 18:37:13 EDT 2011


Hi, Bill - here's an idea.  I created a stack with a button (Button1), 3 
rectangle graphics (R1, R2, R3) and a field (data).
The id's of the rectangles are 1011, 1012 and 1013 (referenced in the 
button script).
If you touch 1, 2 or 3 rectangles at the same time, the total is 
displayed in the field.
This code could be used for many objects - I guess 10 is a practical 
limit unless you take your socks off  ;P

HTH


Card script;

on openCard
    set the behavior of grc "R1" to the long id of btn "Button1"
    set the behavior of grc "R2" to the long id of btn "Button1"
    set the behavior of grc "R3" to the long id of btn "Button1"
end openCard



Button1 script;

on touchStart
    put the id of me into tCurrentId

    # the object id's to monitor
    put "1011,1012,1013" into tIdList

    # record time of current touch against the card
    put the millisecs into tMillisecs
    set the uTouchTime[tCurrentId] of this card to tMillisecs

    # we'll count the number of objects touched simultaneously (or near 
enough)
    put 1 into tSimTouches

    # check each 'other' object in the list
    repeat for each item tId in tIdList
       if tId <> tCurrentId then
          put the uTouchTime[tId] of this card into tTime
          if tTime is an integer and abs(tTime - tMillisecs) < 50 then
             # near simultaneous touch
             add 1 to tSimTouches
          end if
       end if
    end repeat

    # put the total touches into a field
    put tSimTouches into fld "data"
end touchStart



On 02/10/2011 21:12, Bill Vlahos wrote:
> I have two object. Under some circumstances it is fine for only one of them to be tapped but other times it is appropriate for both of them to be tapped at the same time. I don't want to drag them anywhere just touch them.
>
> How do I detect both touches?
>
> Bill Vlahos
> _________________
> InfoWallet (http://www.infowallet.com) is about keeping your important life information with you, accessible, and secure.
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>




More information about the use-livecode mailing list