Game Development Community

Resource: getCurrentCameraPosition();

by Brian Wilson · in Torque Game Builder · 04/11/2005 (9:42 pm) · 3 replies

Since this function doesn't appear to be built in, I thought I'd share my implementation.It's just a small resource(that I didn't see worthy of listing in the resource section) for those of you who can use it.

function getCurrentCameraPosition()
{
  // capture the camera area
  %CurrentCameraArea = sceneWindow2D.getCurrentCameraArea();
  // parse getCurrentCameraArea() into vars
  %x1 = getWord(%CurrentCameraArea, 0);
  %y1 = getWord(%CurrentCameraArea, 1);
  %width = getWord(%CurrentCameraArea, 2);
  %height = getWord(%CurrentCameraArea, 3);
  // calculate the position of the camera
  %x2 = x1 + (width/2);
  %y2 = y1 + (height/2);
  //----------
  // Returns: Un-comment the one (and only one) you want to use
  //----------
  // Simple return of the pivot point of the camera
  //return( %x2 SPC %y2); 
  // standard return of the pivot point of the camera along with dimensions
  //return( %x2 SPC %y2 SPC %width SPC %height); 
}

#1
04/11/2005 (9:44 pm)
Good helper function... just one note


function getCurrentCameraPosition()

forgot the a
#2
04/11/2005 (9:47 pm)
Thanks Matt, fixed it. I also changed it to do a single getCurrentCameraArea() instead of calling it for each of the local vars.
#3
04/12/2005 (1:14 am)
There is a "getCurrentCameraPosition()" in the update!

It's amazing how I could've missed that!

- Melv.