Game Development Community

Scenewindow question

by Chris · in Torque Game Builder · 06/04/2005 (7:37 pm) · 3 replies

I would like to have to so that as long as the area of a tilemap you are viewing isnt at the end of its world limit then it would follow the player. Much like Zelda where as long as the player isnt close to the worldlimit the camera keeps the player in the center of the screen. I looked but could not find any functions that would allow me to do this. I can set it so the whole thing scrolls but I really want to keep the map in the same place and just change the area you are viewing. Anyone have any tips or examples I can look at?

#1
06/04/2005 (10:15 pm)
Maybe .setViewLimitOn (check the reference docs), I beleive this might do what you want it.
#2
06/05/2005 (10:02 am)
T2D makes doing this really easy!

Matt's right, you use .setViewLimitOn()

I had a demo of this working a while back with my player wandering around a tile map, IIRC I mounted the camera to my player and then restricted the camera movement
e.g.
sceneWindow2D.mount( $player );
sceneWindow2D.setViewLimitOn( "-100 -100 100 100" );

You need to ensure that your player can't wander outside of the viewing area though!!
But that's easy enough with a world limit.
#3
06/05/2005 (2:03 pm)
Oh ok, cool. That you very much.