Game Development Community

Back ground scrolling

by Lanny · in Torque X 2D · 02/18/2007 (3:28 pm) · 13 replies

Hello, i am wondering about scrolling back grounds. I have made a bunch already while playing with torquex. but i was wonderintg how to make the backgroubnd scroll once the character gets close enought to the endo of the screen. like mario or double dragon2 sort of an idea.


Thanks

#1
02/18/2007 (6:57 pm)
Those are two different ideas I think. Are you talking about the scroller icon that comes in TGBX? Thats used to create the illusion of movement. Double dragon or mario would be done in Torque X by panning the camera across the background.
#2
02/19/2007 (8:02 am)
Just to expand on this a little. Basically, you would create a really wide (or tall if your players move bottom to top instead of left to right) that goes the entire extent of your level. Then, you would check for the player's position relative to the camera and when he got close enough to any of the edges, you would pan the camera like Modern suggested.

Make sense?

www.linkedin.com/img/webpromo/btn_viewmy_160x25.gif

www.mmogamedev.info/images/imgdc_ad1.gif
#3
02/20/2007 (3:53 am)
Thanks actually yeah that helps, i was just trying to figure out whta the hell to do. I tried a bunch of ideas which didn't really work to well lol i will thry the camera idea tonight after work ( we are not allowed to work on outside projects at work and if we get caught programming could lead to termination)

thanks!
#4
02/20/2007 (6:12 pm)
Actually, when he gets too close to the edge, you would "stop" panning the camera. To be technically precise.
#5
02/25/2007 (11:06 pm)
Has anyone come up with a good way to accomplish panning the camera? Starting from the starter game, in the ProcessTick() method of the MovementComponent, I tried setting the main camera's CenterPosition property to the player's current position, but this caused a noticeable "stutter" which seems to be caused by the camera not updating on every frame. This leads me to believe that ProcessTick() isn't called every frame as I previously thought.

My other option I'm exploring is to "mount" the camera to a link point on the player, but I'm still confused as to how to name link points in the Torque Game Builder X. I can create a link point just fine, but I don't know how to name it -- the T2DLinkPointComponent doesn't show any properties. Do I have to edit these outside of TGBX for this beta?
#6
02/26/2007 (5:17 am)
ProcessTick is not called every frame it is called every tick. InterpolateTick is called every frame and UpdateAnimation is called every frame.

You are on the right track with mounting the camera. If you want it to follow your player then I think that is the "best" solution without knowing details about your specific game.

Yes, you have to add names for your link points outside of TGBX for the beta.
#7
02/26/2007 (12:16 pm)
Wait, I seem to remember naming the linkpoints and every time I saved the level in TGBX it would overwrite my names with "Linkpoint1" and "Linkpoint2" and so on. Has this been fixed?

www.linkedin.com/img/webpromo/btn_viewmy_160x25.gif

www.mmogamedev.info/images/imgdc_ad1.gif
#8
02/26/2007 (1:11 pm)
If you manually edit your scene file outside of TGBX and add properties that aren't readable/writeable from TGBX then I guarantee you will lose them every time. You will need to name them in code or even create them programmatically to begin with. During the open beta that is going to be the only solution to having named link points if you want to use TGBX.
#9
02/26/2007 (11:31 pm)
Ben, you mentioned that InterpolateTick is called every frame but that hasn't been my experience. Are you sure about this? I'm setting the camera CenterPosition to the player's position on each call to InterpolateTick but I'm still getting the "stutter". When I mount to linkpoints, I don't get this stutter.
#10
02/26/2007 (11:58 pm)
Well, I would say I'm about 85% sure but that is also 15% not sure :)

If you are trying to set the camera to the player's position every frame then I say mounting is the "correct" solution anyway, but who the heck am I to say what is correct for your game? :) x2
#11
02/27/2007 (12:15 am)
Okay Ben, sounds good. :) I was going to use the mounting functionality but instead I opted for creating a FollowCameraComponent which I added to my player, which implements IAnimatedObject and updates the camera position on each call to UpdateAnimation. I know this doesn't seem proper, but it seems like it gives me finer control over the follow behavior and the world limits of the camera. I'm sure that a few weeks from now I'll be laughing at myself for using such a non-optimal solution, but at least it's working so far. Until I learn how to properly set up the default camera with a non-null WorldLimit, I'll have to do it this way.
#12
02/27/2007 (8:17 am)
You could use a hybrid solution. The FollowCameraComponent can mount itself to its owner in the _InitComponent method and unmount itself in the _Unregister method (or whatever the equivalent is called in the version you are using).
#13
03/06/2007 (8:03 am)
Similar to this, I am trying to pan TileLayers without the player actually moving, just the background tile layers will be moving. Much like in TGBs ScrollerDemo.

Any ideas?