Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Touch Questions

edited June 2012 in Questions Posts: 2

Hi. I'm developing a board game that has a small amount of hidden information. I'm trying to make some areas on the screen where if the user places the edge of their hand down, the information will appear and then be hidden when they lift their hand. My first idea was to store the id of touches that BEGIN in the zone and then when that touch ends remove that touch from the table. Then when there are no touches in the table I'll hide the information. This works very well for discreet fingertip touches but when I put the edge of my hand down 15 or so touches get registered rapidly and when I lift my hand many of them do not get ENDED messages. Also every so often the four-finger app switch will be triggered with seems to stop Codea event processing and when it comes back the touches are gone.

So first any ideas about this or a better way.

Second, it would probably be sufficient to just hide the data if there are no current touches on the screen. Is there a way to determine this? The CurrentTouch always has a value even if there are no touches going on.

Thanks for any ideas.

Tagged:

Comments

  • dave1707dave1707 Mod
    Posts: 7,683

    tharkad

    See if this code is what you're after. The first touch is kept and any touch after that is ignored until the first touch is lifted. Also, you can use curr_ id to determine if you display or hide your data. Add what code you need where I have the print CurrentTouch information.

    Dave


    -- Use this function to perform your initial setup function setup()     curr_id=0 end -- This function gets called once every frame function draw()     -- This sets a dark background color      background(40, 40, 50)    end function touched(t)     if t.state == BEGAN and curr_id == 0 then         curr_id = t.id         print(CurrentTouch.x,CurrentTouch.y)     elseif t.state == ENDED and t.id == curr_id then         curr_id = 0     end  end
Sign In or Register to comment.