I know this is a common topic and C2 also has a tutorial built in for this.
This one is a bit different.
I used the C2 tutorial to get my touch zoom and pan to work correctly, and it does.
I added a UI Button that when pressed will Zoom and Pan to a specific point.
It uses an invisible object, ScrollTo behavior, and litetween.
The tutorial and the UI Button have their own variables.
The only thing they have in common is LayoutScale, ScrollX and ScrollY.
The UI Button logic is below the Touch Pan/Zoom in the event sheet.
If player touches screen while game is auto zooming/panning it gets ignored.
This is because ScrollX, ScrollY and LayoutScale gets overwritten each tick when ran.
During runtime, sometimes out of nowhere LayoutScale, ScrollX and ScrollY both get set to NAN and screen goes black.
It doesn't happen often and I can't detect a pattern to it.
I can't even reproduce it.
I believe this is the issue.
The Tutorial uses a Layer with Scale rate 0 and Parallax of 0,0.
The Invisible object is on a layer that has Scale rate of 100 and Parallax of 100,100.
I figure the math of the original tutorial is messing up because of this.
I am very sure it has to do with ScrollX and ScrollY and not to do with LayoutScale.
I did think maybe the litetween was interfering somehow...
I am only hoping for the built in C2 Example Tutorial with a few added events, but if someone has something more simple I would appreciate it.
I did study it to a point, but I only understand about 98% of the Example Tutorial.
I mostly just copied it and pasted it into my own project and changed the variable names a small bit.
I am curious if someone could share a capx with Touch Pan/Zoom with the ability to Pan/Zoom to a specific point when the game calls for it.
Maybe use the
"Example: Touch - zooming" capx
and add a feature to zoom and Pan to any given spot on button touch.
I would ask for an explanation on how to fix it, but I lack the ability to test zoom touch when developing...
Thanks in advance.