Scrolling background manager
by Jemand den es nicht gibt · in Torque Game Builder · 12/02/2006 (7:15 am) · 5 replies
Heya!
After I heard 1.1.3 was out I decided to come back and finally do some game prototyping again. :)
Anyway, I am trying to build a script class that manages parallax scrolling backgrounds using scrollers and sprites(for non-moving backdrops). I started off trying to implement that kind of background that stays in the far back all the time, not moving. My current setup is:
- sceneWindow2D mounted to an invisible camera scene object using a variable force
- Camera mounted to objects, also allowing for an offset
The camera itself is working great.. I can make my character look up and down like in old platformers.
I tried to mount the backdrop sprite to the camera object but that doesn't work well as I don't use zero for force.. the object is in the right position relative to the scene window after it reaches the camera object. Well damn. :) Then I tried to update the backdrops position in onUpdateScene using
Backdrop.setPosition(sceneWindow2D.getCurrentCameraPosition());
This almost works but the object still doesn't fit perfectly alligned to the camera(ie. black stripes between backdrop and window extent if you move around the character).
I thought getCurrentCameraPosition would give you the correct coordinates. Does anyone know how to solve that problem? I'm pretty much stuck now..
After I heard 1.1.3 was out I decided to come back and finally do some game prototyping again. :)
Anyway, I am trying to build a script class that manages parallax scrolling backgrounds using scrollers and sprites(for non-moving backdrops). I started off trying to implement that kind of background that stays in the far back all the time, not moving. My current setup is:
- sceneWindow2D mounted to an invisible camera scene object using a variable force
- Camera mounted to objects, also allowing for an offset
The camera itself is working great.. I can make my character look up and down like in old platformers.
I tried to mount the backdrop sprite to the camera object but that doesn't work well as I don't use zero for force.. the object is in the right position relative to the scene window after it reaches the camera object. Well damn. :) Then I tried to update the backdrops position in onUpdateScene using
Backdrop.setPosition(sceneWindow2D.getCurrentCameraPosition());
This almost works but the object still doesn't fit perfectly alligned to the camera(ie. black stripes between backdrop and window extent if you move around the character).
I thought getCurrentCameraPosition would give you the correct coordinates. Does anyone know how to solve that problem? I'm pretty much stuck now..
#2
Does anybody know workarounds?
12/02/2006 (11:23 am)
Hmm, I found 2 more major issues with my system, bah. :D I have the static background now and 2 parallax scrolling backgrounds. With the scrolling backgrouns the jittering on swift camera movement is still very visible and annoying. Also when I limit the view area of the scene window it seems the position just gets clamped but the real position returned by getCurrentCameraPosition is still over the view limit which causes the backgrounds to move out of the view space.Does anybody know workarounds?
#4
12/05/2006 (2:36 am)
I wrote a parallax manager that can use either scrollers or scene object groups, but the scenegraph route is much easier. Just load multiple scene windows with the background layers and change the zoom. You can do other cool stuff with this, like move a player between scenegraphs and have the player travel across the background (think Abe's Odyssey). I've played with this a little bit and it makes for some really interesting gameplay.
#5
12/05/2006 (6:54 am)
Yeah, using multiple scenegraphs you can do really cool stuff. :) Once again proved that your imagination is the limit. ;)
Torque Owner Jemand den es nicht gibt