Pinch Zoom...and Pan Image working together in harmony?

In my perfect world, I want to be able to pinch zoom, and at any time, pan the image around.

I have a single image loaded, and individual listeners to accomplish both of the needed functions, when applied one at a time, works perfectly.

I am looking for input from the community on how to get both to live together and work together.

Both listeners are listening for the “touch” event, so I am thinking I need to either figure out an event to listen to that isn’t “touch”, or… that is where I lose my train of thought. I just can’t seem to wrap my head around how to accomplish it.

I will take any and all ideas at this point. [import]uid: 5317 topic_id: 15636 reply_id: 315636[/import]

In my imperfect world, I go about doing things that may not be entirely efficient, but since you say you will take any and all ideas…

Since you have both functions working, what if you place two display object, one loads the image and the other a transparent rectangle the same size as the loaded image, and attach one “touch” event to the image and another to the transparent rectangle – and have these two objects always placed on exactly the same x,y coordinate? [import]uid: 67217 topic_id: 15636 reply_id: 57794[/import]

Now that is an interesting idea, if I have the pinch zoom above the pan, I can allow single touches (panning) to fall through the pinch zoom…

Off to test. [import]uid: 5317 topic_id: 15636 reply_id: 57813[/import]

Let us know how it goes. Good luck!

EDIT: One more thought… you might be able to group the two objects into displayGroup… [import]uid: 67217 topic_id: 15636 reply_id: 57818[/import]

Still testing, so far no joy… [import]uid: 5317 topic_id: 15636 reply_id: 57824[/import]

@mike4… Did you ever get this working?
Cheers
Richie [import]uid: 12583 topic_id: 15636 reply_id: 62045[/import]

Nope, not yet.

I will work on it when the app is released, and put it out as an update. [import]uid: 5317 topic_id: 15636 reply_id: 62085[/import]

@Mike4
Hey Mike… I played around with the PinchZoomGesture and DragMe sample code today… and came up with this:

Open the PinchZoomGesture sample code and:

Create the following 2 new entries

self.x0 = event.x - self.x



self.y0 = event.y - self.y

…below line 66

if "began" == phase then

And then add the following

if numTotalTouches \< 2 then



self.x = event.x - self.x0



self.y = event.y - self.y0

below line 104

if "moved" == phase then

Now give that a whirl and see how it goes!
It works ok for me… I’d just like to get the scale to work around the origin of the actual pinch. Tried xReference but didnt work… caused some snapping when dragging.

Its getting there
Richie

[import]uid: 12583 topic_id: 15636 reply_id: 62104[/import]

Found this: http://developer.anscamobile.com/code/Pinch-Zoom-XL

Very Useful. [import]uid: 44110 topic_id: 15636 reply_id: 99241[/import]