Resolved: Sprite collide / onLimit with Window edge?
by Chris Jorgensen · in Torque Game Builder · 09/04/2007 (10:12 pm) · 3 replies
I have my sprites floating around on a 2D plane. As they get further apart from one another, the camera zooms out, keeping all the sprites in view. This has been working well for me. My trouble, however, is syncing up the onWorldLimit settings such that when the maximum zoom has been hit, the sprites move without camera zoom until they hit the edge of the scenewindow. At which point, ala Asteroids, they wrap around to the other side of the plane. My problem is that either the sprites wrap around before they've hit the edge, or after they're almost completely off-screen.
I suspect there's a way to do some sort of onLimit callback for hitting the edge of the visible scenewindow. That way even if I were to do different playable planes/levels, I'd know for sure that the wraparound would only occur once the ships hit the edge of the visible scene. I just don't know how to implement it. Does anyone have any experience or ideas on this?
Edit: replaced "scenegraph" with correct term "scenewindow"
I suspect there's a way to do some sort of onLimit callback for hitting the edge of the visible scenewindow. That way even if I were to do different playable planes/levels, I'd know for sure that the wraparound would only occur once the ships hit the edge of the visible scene. I just don't know how to implement it. Does anyone have any experience or ideas on this?
Edit: replaced "scenegraph" with correct term "scenewindow"
About the author
Owner of Cascadia Games LLC
#2
The closest type thing that I've found thus far is the Window/World space conversion functions, found here tdn.garagegames.com/wiki/TGB/Reference:_Glossary#Window_Space
I'm not sure if anyone has tried it or if I'm misinterpreting possible uses of the window space functions.
09/05/2007 (8:30 am)
Yes, I mean the scenewindow. It's a non-trivial problem, however. I need to be able to support different level sizes. Synchronizing the zoom / world limits such that the ships always perfectly hit the edge of the window before wrapping has proved difficult to achieve. Plus, the window isn't perfectly square, hence there's a lot of hard-coded tweaking to get things to look right for multiple level sizses.The closest type thing that I've found thus far is the Window/World space conversion functions, found here tdn.garagegames.com/wiki/TGB/Reference:_Glossary#Window_Space
I'm not sure if anyone has tried it or if I'm misinterpreting possible uses of the window space functions.
#3
%upper_left = sceneWindow2D.getWorldPoint(0,0);
%lower_right = sceneWindow2D.getWorldPoint(632,600);
%left = getWord(%upper_left,0);
%top = getWord(%upper_left,1);
%right = getWord(%lower_right,0);
%bottom = getWord(%lower_right,1);
And it works pretty well. Then I just anchor the camera such that it doesn't drift away from a center box and it works fabulously. This is going to fit great with my forthcoming beta. :)
09/05/2007 (10:33 pm)
Okay! So I went ahead and tried this:%upper_left = sceneWindow2D.getWorldPoint(0,0);
%lower_right = sceneWindow2D.getWorldPoint(632,600);
%left = getWord(%upper_left,0);
%top = getWord(%upper_left,1);
%right = getWord(%lower_right,0);
%bottom = getWord(%lower_right,1);
And it works pretty well. Then I just anchor the camera such that it doesn't drift away from a center box and it works fabulously. This is going to fit great with my forthcoming beta. :)
Torque 3D Owner Marc Dreamora Schaerer
Gayasoft
I assume you are talking of the edge of the scenewindow?
You problem sounds like the world limits are not set to the correct size when you get this problem. Did you try to use the scenegraphs debug stuff like the objects world limits for example to check where the worldlimit is in real? Sounds like this is actually the problem.
if you want to do it manually you would need to use the tick callback and check it on every tick, by just looking if they are in view for example.