Hello,
how to scale a picture with a multi touch ?
I tried with " system.activate(“multitouch”) " and next " im:addEventListener(“touch”,im) " etc … but i never focus unless i lost the other event touch.
Sincerely, Yvan.
Hello,
how to scale a picture with a multi touch ?
I tried with " system.activate(“multitouch”) " and next " im:addEventListener(“touch”,im) " etc … but i never focus unless i lost the other event touch.
Sincerely, Yvan.
You have to actually code this… for each touch you store the relevant x,y positions. If they are increasing relative to each other then you are zooming in , if decreasing then you are zooming out. You then scale accordingly.
you’re looking for a module that does pinch, zoom, and rotate.
There are few out there, but they may be old.
SSK2 Contains a pinch-zoom listener (not documented! bad me)
However, it is this easy to use:
-- in main.lua -- Load and init ssk2 in main.lua require "ssk2.loadSSK" \_G.ssk.init() -- Activate multi-touch system.activate("multitouch")
then later
-- make the object local obj = ssk.display.newImageRect( nil, centerX, centerY, "ssk2.jpg", { w = 730, h = 300 }) -- Attach listener from SSK2 lib obj.touch = ssk.easyIFC.pinchZoomDragTouch -- Start listening for touch obj:addEventListener("touch")
ah but does it also pan as you are pinching? and does it work as a runtime handler or object handler?
The answer is in the name: pinchZoomDragTouch
To be explicit. It allows drag and pinch-zooming, not rotating/panning.
Having said that, SSK2 is easily extended.
Also, it’s a object listener. I’m not sure how you’d approach this as a Runtime listener. That seems like it would be kind of messy and error prone.
PS - I may be wrong about the runtime listener, but I must admit I almost never use Runtime touch listeners, except in combination with object listeners to make editors. 99% of the time I use object listeners for touch, collision, etc.
I use a runtime listener for pan and zoom as user interaction can occur both on and off any objects or sometimes one finger on and the other off. without a runtime listener there would be strange and inconsistent behaviour.
I also use object listeners to move objects independent of the background. It was tricky getting it to work!
There is a sample app in the samples that ships with Corona SDK in SampleCode/Interface/PinchZoomGesture that shows you how to pinch-zoom an image.
Rob
wonderful, thanks
You have to actually code this… for each touch you store the relevant x,y positions. If they are increasing relative to each other then you are zooming in , if decreasing then you are zooming out. You then scale accordingly.
you’re looking for a module that does pinch, zoom, and rotate.
There are few out there, but they may be old.
SSK2 Contains a pinch-zoom listener (not documented! bad me)
However, it is this easy to use:
-- in main.lua -- Load and init ssk2 in main.lua require "ssk2.loadSSK" \_G.ssk.init() -- Activate multi-touch system.activate("multitouch")
then later
-- make the object local obj = ssk.display.newImageRect( nil, centerX, centerY, "ssk2.jpg", { w = 730, h = 300 }) -- Attach listener from SSK2 lib obj.touch = ssk.easyIFC.pinchZoomDragTouch -- Start listening for touch obj:addEventListener("touch")
ah but does it also pan as you are pinching? and does it work as a runtime handler or object handler?
The answer is in the name: pinchZoomDragTouch
To be explicit. It allows drag and pinch-zooming, not rotating/panning.
Having said that, SSK2 is easily extended.
Also, it’s a object listener. I’m not sure how you’d approach this as a Runtime listener. That seems like it would be kind of messy and error prone.
PS - I may be wrong about the runtime listener, but I must admit I almost never use Runtime touch listeners, except in combination with object listeners to make editors. 99% of the time I use object listeners for touch, collision, etc.
I use a runtime listener for pan and zoom as user interaction can occur both on and off any objects or sometimes one finger on and the other off. without a runtime listener there would be strange and inconsistent behaviour.
I also use object listeners to move objects independent of the background. It was tricky getting it to work!
There is a sample app in the samples that ships with Corona SDK in SampleCode/Interface/PinchZoomGesture that shows you how to pinch-zoom an image.
Rob
wonderful, thanks