Touch Questions

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.


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.


-- Use this function to perform your initial setup
function setup()

-- This function gets called once every frame
function draw()
    -- This sets a dark background color 
    background(40, 40, 50)   

function touched(t)
    if t.state == BEGAN and curr_id == 0 then
        curr_id =
    elseif t.state == ENDED and == curr_id then
        curr_id = 0