Howdy, Stranger!

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

In this Discussion

Multi Touch Problem

So… I have two controllers that you control with two fingers, one on the left and one on the right. Not long ago, I discovered that if I move my controllers with two fingers moving on the screen, one of the controllers will start glitching like crazy, and will go back and forth different it’s origin position and the position that the finger is at. Is there anyway to fix this problem??

Thanks in advance :)

Comments

  • dave1707dave1707 Mod
    Posts: 9,441

    Try this using one or two or all of your fingers. If you want, you can add code to limit the number of touches.

    function setup()
        tab={}  -- table of touches
    end
    
    function draw()
        background(40,40,50)
        fill(255)
        text("move one or more fingers on the screen",WIDTH/2,HEIGHT-50)
        for z=1,#tab do
            ellipse(tab[z].x,tab[z].y,120)
        end
    end
    
    function touched(t)
        if t.state==BEGAN then
            table.insert(tab,vec3(t.x,t.y,t.id))    -- put x,y,id in table
        elseif t.state==MOVING then
            for a,b in pairs(tab) do
                if t.id==b.z then    -- id matches entry in table
                    tab[a]=vec3(t.x,t.y,t.id)  -- update x,y,id in table
                    return            
                end
            end
        elseif t.state==ENDED then
            for a,b in pairs(tab) do
                if t.id==b.z then   -- id matches entry in table
                    table.remove(tab,a)    -- remove entry from table
                end
            end
        end
    end
    
Sign In or Register to comment.