Multitouch

Hi to all the community)

I have a rather simple question: how to add multitouch support for already created touch events in my code?
I dont want to rewrite them for known reasons. I tried to look at demo apps that comes with sdk, but just got confused

thanks in advance [import]uid: 16142 topic_id: 19138 reply_id: 319138[/import]

Hey there,

Chances are you wont have to rewrite any code for multitouch - give it a test and see if it all behaves like you want.

To enable multitouch just add;

[lua]system.activate(“multitouch”)[/lua]

Let me know how you go.

Peach :slight_smile: [import]uid: 52491 topic_id: 19138 reply_id: 73858[/import]

Thanks for answer Peach, but it wont work for me as i need
i have an objects that i need to just touch and objects that i need to drag, if seems they wont behave with together properly…
i need to be able to drag on thing and at the same time touch on others…

is that possible?
right now my drag function looks like this:
[lua] local function onTouch(_e)
local t = _e.target

local phase = _e.phase
if “began” == phase then

local parent = t.parent

display.getCurrentStage():setFocus( t )

t.isFocus = true

–t.x0 = _e.x - t.x
t.y0 = _e.y - t.y
elseif t.isFocus then
if “moved” == phase then

–t.x = _e.x - t.x0
t.y = _e.y - t.y0

elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false

end
return true
end
end[/lua] [import]uid: 16142 topic_id: 19138 reply_id: 73963[/import]

Hey,

OK, yeah, setting focus will need a little adjustment - see here; http://developer.anscamobile.com/reference/index/stagesetfocus

Peach :slight_smile: [import]uid: 52491 topic_id: 19138 reply_id: 74119[/import]

so my drag function now needs to look like this?:
[lua] local function onTouch(_e)
local t = _e.target

local phase = _e.phase
if “began” == phase then

local parent = t.parent

display.getCurrentStage():setFocus( t , event.id)

t.isFocus = true

–t.x0 = _e.x - t.x
t.y0 = _e.y - t.y
elseif t.isFocus then
if “moved” == phase then

–t.x = _e.x - t.x0
t.y = _e.y - t.y0

elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( t, nil )
t.isFocus = false

end
return true
end
end[/lua]

i dont quite understand meaning of touchID there, and just wrote event.id in set focus… [import]uid: 16142 topic_id: 19138 reply_id: 74171[/import]

I believe in this case you would use _e.id and not event.id because of how you’ve set up the function.

Test that and let me know if it’s all good :slight_smile:

Peach [import]uid: 52491 topic_id: 19138 reply_id: 74309[/import]