touch.tapCount

How to use this method properly?

if  CurrentTouch.state == ENDED then
    if  CurrentTouch.tapCount == 1 then
        print("condition 1")
    else
        print("condition 2")
    end
end

Since the tapCount is evaluated after each ENDED state, the “condition 1” gets fired anyways. How to avoid that - is there any elegant way?

Try something like this. As long as each tap is less than .3 seconds that I have in the if statement, then it will give you the final tap count. Change the .3 seconds to a value you need. Just tap the screen to try different tap counts.


function setup()
    tc=0
    et=0
end

function draw()
    background(40, 40, 50)
    fill(255)
    if ElapsedTime-et>.3 then
        text("tap count     "..tc,WIDTH/2,HEIGHT/2)
    end
end

function touched(t)
    if t.state==ENDED then
        tc=t.tapCount
        et=ElapsedTime
    end
end

(Deleted) Dave1707 beat me to it

thank you! worked perfectly)

I am trying to get it to where if I touch in an axis my sprite will go+ whatever amount insted of it going on o my finger PLZ help

-- frogger 2.0
supportedOrientations(LANDSCAPE_ANY)
frogimg = "Documents:frog for frogger"

function setup()
    displayMode(FULLSCREEN)
    frog = Frog(frogimg)
    frog.position = vec2(WIDTH/2.5,HEIGHT/4)
    L1=log(900,550,300,35)
end
function touchingAtPos()
    if CurrentTouch.state == BEGAN then
        --  CurrentTouch.state == MOVING then
        return vec2( CurrentTouch.x, CurrentTouch.y )
    end
    return nil
end

-- This function gets called once every frame
function draw()
    -- This sets a dark background color
    background(0, 0, 255, 255)
    L1:draw()
    frog:draw()
    
    -- This sets the line thickness
    strokeWidth(5)
    
    -- Do your drawing here
    
    touch = touchingAtPos()
    if touch then
        if touch.x < (frog.position.x - 10) then
            frog.position.x = frog.position.x - 23
            elseif touch.x > (frog.position.x + 10) then
            frog.position.x = frog.position.x + 23
        end
        
        if touch.y < (frog.position.y - 10) then
            frog.position.y = frog.position.y - 23
            elseif
            touch.y > (frog.position.y - 10) then
            frog.position.y = frog.position.y + 23
            
            --if touch.y > frog.position.y then
               -- frog.position.y=frog.position.y+25
        end
    end
end 

@minersack27 Try using this bit of code:

frog.position.x = frog.position.x + touch.deltaX
frog.position.y = frog.position.y + touch.deltaY

Where would I put that

@minersack27

if touch then
    paste code here
end