tracking multiple touches

I am trying to make a game with two main buttons, one to rotate the view and one the direction you run in. It is coming out good, but I can’t get Codea to let me use both buttons simultaneously. What I want to do is create something like the Ping sample game in Codea, and have two touches exist at once. Anyone know how?

@jrohanian Here’s a simple example. Slide a finger back and forth. Then try more fingers.


displayMode(FULLSCREEN)

function setup()
    mt={}    -- touch table
end

function draw()
    background(40, 40, 50)
    z=0
    for a,b in pairs(mt) do
        z=z+1
        sprite("Planet Cute:Character Boy",b.x,HEIGHT-100*z)
    end     
end

function touched(t)
    if t.state==BEGAN then
        mt[t.id]=t
    end           
    if t.state==MOVING then
        mt[t.id]=t
    end
    if t.state==ENDED then
        mt[t.id]=nil
    end
end

@dave1707 's example is good. Codea also has a built in example that you can look at.

@dave1707 Thanks I get it now. I was making this way too complicated.