Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
How do I set the maximum Touch events? — Gideros Forum

How do I set the maximum Touch events?

MillerszoneMillerszone Member
edited October 2011 in General questions
With the example "Touch Explorer" you can have five dots or 5 touches.
If you touch more than 5 times the app will crash.

With my app I only need a max of 2 touches at a time.
So I need something like this example:
if #event.touches > 2 then totalTouches = 2 end
local dots = {dot1, dot2} 
 
local function onTouchesMove(event)
	for i=1,totalTouches do
	local dot = dots[event.touches[i].id]
	dot:setPosition(event.touches[i].x, event.touches[i].y)
	end
end
Thanks

Likes: tytadas

+1 -1 (+1 / -0 )Share on Facebook

Comments

  • atilimatilim Maintainer
    You're right. I've recently found that bug and fixed it.

    Thank you.
  • For a max of 2 touches, I'm using this, it seems to work o.k for now.
    local function onTouchesBegin(event)
       for i=1,#event.touches do
    	if event.touches[i].id > 2 then event.touches[i].id = 2 end
    	paddle = paddles[event.touches[i].id]
    	stage:addChild(paddle)
       end
    end
  • atilimatilim Maintainer
    edited October 2011
    I think, totally ignoring the touches with id > 2 is more suitable:
    local function onTouchesBegin(event)
        for i=1,#event.touches do
            if event.touches[i].id <= 2 then
                paddle = paddles[event.touches[i].id]
                stage:addChild(paddle)
            end
        end
    end
    With your code, you can control the 2nd paddle with the 3rd touch :)
  • Yes, your way is better, but after looking over my code, I really didn't need
    the above extra code.
    What I was doing was adding: stage:addChild(paddle) when I didn't need it,
    that was causing the crash.

    Thanks
Sign In or Register to comment.