[Resolved] Fire function when 2 fingers are touching the screen

Hi Ansca Community

First I wanna thank all the helpful souls, who have been fast on the keyboard to answer all my questions, I have asked lately. It is very appreciated.

Now to my question: I need a pause screen/function in my game and I want this function to be triggered when two fingers are touching/tapping the screen. Is this possible at all?

Thank you in advance

[import]uid: 122802 topic_id: 26408 reply_id: 326408[/import]

Hey there,

This is really rough but I think it will give you something to go on - if you tap with two fingers at once it will show a square in the corner that will disappear after one second.

Hopefully you can clean it up and build on it to suit your purpose :slight_smile:

[lua]system.activate(“multitouch”)

bg = display.newRect( 0, 0, 320, 480 )
bg:setFillColor(255,0,0)

local touches = 0

local function tapIt (event)
if touches < 2 and event.phase == “began” then
print “X”
touches = touches + 1
end
if touches == 2 then
local test = display.newRect( 0, 0, 50, 50 )
timer.performWithDelay(1000, function() test:removeSelf() end, 1)
end
if event.phase == “ended” then
touches = touches - 1
end
end
bg:addEventListener(“touch”, tapIt)[/lua]

Peach

PS - Remember this must be tested on device as the simulator does not support multitouch. [import]uid: 52491 topic_id: 26408 reply_id: 107172[/import]

Hi Peach

Thank you very much for your quick response and the code. It is working like a charm :).

[import]uid: 122802 topic_id: 26408 reply_id: 107365[/import]

Excellent! Marking as resolved :slight_smile: [import]uid: 52491 topic_id: 26408 reply_id: 107557[/import]