Hello Guest

Author Topic: Dolly in and out with tk2d Camera (Orthoganal)?  (Read 5058 times)

outtoplay

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 24
    • View Profile
Dolly in and out with tk2d Camera (Orthoganal)?
« on: June 21, 2012, 02:37:33 pm »
I have a 2d scrolling game (endless scroller), where the player controls a bird flying to the right.  I"m using a tk2dCamera set to Ortho and a size of 1536. I'd like to dolly out a little wider when the character moves vertically in the scene. Normally I'd say a float value could be used in the Ortho size keyed to the bird's vertical movement, but with the tk2dCamera I believe the texture atlases are keyed off that number.  Would there be any negative implications to using a tk2dCamera and animating in game the Otho size?

thanks,
B.


« Last Edit: June 21, 2012, 06:57:17 pm by unikron »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Dolly in and out with tk2d Camera (Orthoganal)?
« Reply #1 on: June 21, 2012, 06:57:40 pm »
Accidentally edited that into your message there -

This isn't possible right now with the ortho size parameter, as everything is overriden by the custom projection matrix used here. You could however, use the resolution override "scale" parameter to scale this. Don't forget that the tk2dCamera's origin is in the bottom left, so scaling this up or down will pivot at that point. Anyway, if this works I could easily add a global scale value much like the ortho size paramter.

I have a 2d scrolling game (endless scroller), where the player controls a bird flying to the right.  I"m using a tk2dCamera set to Ortho and a size of 1536. I'd like to dolly out a little wider when the character moves vertically in the scene. Normally I'd say a float value could be used in the Ortho size keyed to the bird's vertical movement, but with the tk2dCamera I believe the texture atlases are keyed off that number.  Would there be any negative implications to using a tk2dCamera and animating in game the Otho size?

thanks,
B.


outtoplay

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Dolly in and out with tk2d Camera (Orthoganal)?
« Reply #2 on: June 21, 2012, 08:33:43 pm »
yeah scaling up from the corner wouldn't work. would need to appear to be pulling back the camera as the bird flew higher.  Sounds like I should be using a regular ortho cam?  Damn, I like the way everything is scales to match the camera.  But I do want this effect.

thanks,
B.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Dolly in and out with tk2d Camera (Orthoganal)?
« Reply #3 on: June 21, 2012, 11:32:54 pm »
2 options.
1 - you can modify the tk2dCamera matrix to be off center, or do some manual offsetting while scaling
2 - You can switch the camera to a normal camera and set the ortho size correctly to display 1:1 at any resolution. Basically, the ortho size needs to be 0.5 * screen height. A really simple script which sets this on Start() will do the job. You can still keep a second tk2dCamera for any UI elements, just make sure you set depth to be bigger than the first camera, and set clearflags to depth only or none.