Hello Guest

Author Topic: Change tk2dCamera scale dynamically with code?  (Read 4995 times)

theremin

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 20
    • View Profile
Change tk2dCamera scale dynamically with code?
« on: May 31, 2012, 01:46:24 am »
How can I change the Scale for the tk2dCamera dynamically with code? I don't want to have to create dozens of different Resolution Overrides for all sorts of different devices and monitors; I'd prefer to just set the scale dynamically with code according to a handful of resolution ranges. Is this possible?

Basically, I'm looking for something like this:

Code: [Select]
td2kCamera.inst.currentScale = 2f;

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Change tk2dCamera scale dynamically with code?
« Reply #1 on: May 31, 2012, 08:19:33 am »
Not directly like that, but if you set up the override through code in game, then that'll work.

tk2dCamera.inst.resolutionOverride = new ...;
tk2dCamera.inst.resolutionOverride[0].width = resolution;
tk2dCamera.inst.resolutionOverride[0].scale = customScale;

and don't forget to call UpdateCameraMatrix after that...

theremin

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Change tk2dCamera scale dynamically with code?
« Reply #2 on: May 31, 2012, 03:47:45 pm »
Perfect! Thanks!