Howdy, Stranger!

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

Easy Multiple Touch?

edited January 2016 in Questions Posts: 7

I am making a game that needs to allow codea to check to see if both sides of the screen are being pressed at once, together. I am aware there is a multitouch project, and I tried to understand it and implement it into my project, but it simply will not work. Any ideas on an easy multiple touch system?

Tagged:

Comments

  • IgnatzIgnatz Mod
    Posts: 5,396

    the demo project is about as easy as it gets

    or you can try searching the forum

  • dave1707dave1707 Mod
    edited January 2016 Posts: 7,810

    @NarwhalKing10 Here's a simple example of multitouch.

    EDIT: The multitouch example is easier, but this doesn't use tables so maybe it will be easier to understand.

    displayMode(FULLSCREEN)
    
    function setup()
        id1=vec3(0,0,0)
        id2=vec3(0,0,0)
    end
    
    function draw()
        background(40, 40, 50)
        sprite("Planet Cute:Character Boy",id1.x,id1.y,200)
        sprite("Planet Cute:Character Horn Girl",id2.x,id2.y,200)
    end
    
    function touched(t)
        if t.state==BEGAN then
            if id1.z==0 then
                id1=vec3(t.x,t.y,t.id)
            elseif id2.z==0 then
                id2=vec3(t.x,t.y,t.id)
            end
        end
        if t.state==MOVING then
            if t.id==id1.z then
                id1=vec3(t.x,t.y,t.id)
            end
            if t.id==id2.z then
                id2=vec3(t.x,t.y,t.id)
            end
        end
        if t.state==ENDED then
            if t.id==id1.z then
                id1=vec3(0,0,0)
            end
            if t.id==id2.z then
                id2=vec3(0,0,0)
            end
        end
    end
    
Sign In or Register to comment.