2D Toolkit Forum

2D Toolkit => Support => Topic started by: gonzalez.martin90 on February 26, 2015, 06:15:13 pm

Title: Zoom with Pixel Per Meter
Post 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?
Title: Re: Zoom with Pixel Per Meter
Post by: unikronsoftware on February 27, 2015, 09:28:43 am
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?
Title: Re: Zoom with Pixel Per Meter
Post by: gonzalez.martin90 on February 27, 2015, 01:22:42 pm
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

Code: [Select]
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;
}
Title: Re: Zoom with Pixel Per Meter
Post by: gonzalez.martin90 on March 02, 2015, 12:38:58 pm
is that code Ok? The value Pixel Per Meter in Tk2dCamera is not changing.
Title: Re: Zoom with Pixel Per Meter
Post by: unikronsoftware on March 02, 2015, 02:45:57 pm
You should just use zoomfactor to change the zoom. Check the tilemap sample - it zooms in and out based on the speed of movement.