Hello Guest

Author Topic: Zoom with Pixel Per Meter  (Read 4845 times)

gonzalez.martin90

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 24
    • View Profile
Zoom with Pixel Per Meter
« 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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Zoom with Pixel Per Meter
« Reply #1 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?

gonzalez.martin90

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Zoom with Pixel Per Meter
« Reply #2 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;
}

gonzalez.martin90

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Zoom with Pixel Per Meter
« Reply #3 on: March 02, 2015, 12:38:58 pm »
is that code Ok? The value Pixel Per Meter in Tk2dCamera is not changing.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Zoom with Pixel Per Meter
« Reply #4 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.