2D Toolkit Forum
2D Toolkit => Support => Topic started by: gonzalez.martin90 on February 26, 2015, 06:15:13 pm
-
Hi!
I'm trying to make zoom in and out but i want to use the pixel per meter. The thing is that i have items achored. Is there a way to override or do something to do zooming and avoid anchors to reposition?
Actually i'm modifying the Zoom Factor but it make no zoom. Seems to scale the camera frustrum but the images still the same size.
Any idea?
-
If the camera frustum is scaling surely you'd see less or more of something that is inside it? Why isn't that happening for you?
-
If the camera frustum is scaling surely you'd see less or more of something that is inside it? Why isn't that happening for you?
I'm modifying the OrthoPixelPerMeter value but in the inspector the camera still have 1 (my default value) but the screen is doing somthing strange. If i manipulate the value from the inspector it does what i want.
My code here
void Start()
{
EasyTouch.On_PinchIn += HandleOn_PinchIn;
EasyTouch.On_PinchOut += HandleOn_PinchOut;
camera = Camera.main.GetComponent<tk2dCamera>();
}
void HandleOn_PinchOut (Gesture gesture)
{
Debug.Log(gesture.deltaPinch);
camera.CameraSettings.orthographicPixelsPerMeter -= gesture.deltaPinch * Time.deltaTime * 5;
}
void HandleOn_PinchIn (Gesture gesture)
{
Debug.Log(gesture.deltaPinch);
camera.CameraSettings.orthographicPixelsPerMeter += gesture.deltaPinch * Time.deltaTime * 5;
}
-
is that code Ok? The value Pixel Per Meter in Tk2dCamera is not changing.
-
You should just use zoomfactor to change the zoom. Check the tilemap sample - it zooms in and out based on the speed of movement.