Game Development Community

Is there a way keep an object from moving during a camera mount?

by Kevin Epps · in Torque Game Builder · 05/05/2008 (5:21 pm) · 10 replies

Let me explain.

I want to have the background scroll within the camera limits, but I want an object to sit above everything else statically, meaning that I want an object to sit "above" the actual stage. So when you're moving around the stage, the object that sits "above" is always visible and doesn't move. Is there a way to do that?

#1
05/05/2008 (5:29 pm)
Isn't that what t2dScroller objects are for? They appear to be moving - but its just a scrolling texture - so it does it does not affect the position of your other objects.
#2
05/05/2008 (6:15 pm)
Well, I have other objects in the background that should also a parallax perception, so I'm using the Parallax Behavior to achieve that and I like the way that part looks.

There will be a lot of stationery action and moving action, so mounting the camera makes that easier for me.

It will kinda have a platformer style to it.
#3
05/05/2008 (7:27 pm)
Well I haven't looked at the parallax behaviors, so I don't have any tips on those, but you could get a parallax effect with just normal t2dScroller objects. Just have more than one of them on different layers with textures that have some transparent areas so you can see them all through each other.

I'm not sure what type of game you are working on, ( and you may already know all of this ), but in many 2D games ( eg. scrolling shooters ), the camera does not have to be mounted to anything, because it actually doesn't move.

The background doesn't have to really move either, it is just a scrolling texture.

Then objects that should move "with" the background ( eg. appear stationary ), just have a velocity to give the effect that they are moving at the same rate as the background is scrolling.

Then object that appear to be moving forward with the camera ( eg. stationary on the screen itself ), just don't have any velocity at all.


This technique requires less processor than having your level actually shaped like a very long rectangle, because there is less to load, etc...
#4
05/05/2008 (7:32 pm)
Kevin, have a look at the new Parallax method described on the Platformer Starter Kit's TDN page. It uses multiple scene windows to display the effect. It works really well too.
#5
05/06/2008 (5:13 am)
I will take a look at that. I purchased that kit when it came out as well. I'll let you guys know what I find.
#6
05/06/2008 (5:44 am)
Hey James,

I would use those scrollers if I could get rid of those white backgrounds for textures that don't have sizes with powers of 2(They were done by freelancers and I'd rather not alter them to get to that size). How can I just make that white part transparent?

If I can do the following, I would be a happy man.

It's a vertical shooter. What happens is that the screen scrolls to a point where you fight a bunch of enemies, once you finish beating them, you "takeoff" and the screen starts scrolling again. I also want the screen to scroll to each horizontal end of the texture and just stop there.

Any way on how to achieve that?
#7
05/06/2008 (9:33 am)
Oh, it looks like you will get a white line down your scroller if it's not power of two. If you are a pro licenser, I'd say look at the onRender method for the t2dScroller object.

I think the scroller object is intended more for smaller textures that loop well so they can continually repeat. If what you have is a very large and detailed background image that you do not need to repeat/loop - You don't actually need a scroller object. You could just make it one big static-sprite ( you can change its velocity to have it start/stop ).

Sorry if I lead you in the wrong direction, since it sounds like you don't really need a scroller.
#8
05/06/2008 (11:12 am)
Phillip, could you just show me an example of how to use that snippet you wrote? I think I'm getting confused because I'm trying to apply it to my situation and can't really figure out how to use it.
#9
05/06/2008 (11:32 am)
Ok, starting to get a hang of the scroller stuff and I'm able to make it suit what I want to do. The main issue was creating a whole world where you would only see certain objects during a certain part of the stage. But I may have a way around that. I'll let you know if it works.
#10
05/08/2008 (3:28 pm)
Also, i think TileMaps are handy in this case too... i use them more than scrollers (actually, i've never really used scrollers) and they work like a charm...