Multiple cameras

Sep 28, 2009 at 5:18 PM

Hey Andy,

I'm trying to do some simple things with multiple cameras.  Basically, I'd like to have two fixed cameras, A and B, and one camera C that follows an object.  When I click on a button (or otherwise generate an event) it toggles between them.

From looking at the classes it seems like I should be able to do this, but I keep running into trouble.  I don't mind debugging this myself, but I wanted to see if you had any advice on how the cameras are organized.  Does the design support the above scenario or am I trying to make it do something it wasn't intended to do?


Sep 28, 2009 at 5:30 PM

I would probably just keep a single Camera and change the target. There shouldn't be any performance cost to this, and the effect would be the same.

Are you using the Physics Helper Behaviors or User Controls? Because if I remember right, the Camera Behavior doesn't have everything exposed yet to change target - but the User Control does. So you might need to get at the underlying Camera Controller object to change target.

Hope this helps?

Sep 28, 2009 at 6:27 PM

Are the modes of operation (user controls vs behaviors) generally independent?  I am trying to use a CameraController with a PhysicsControllerBehavior.  I had to modify CameraControllerMain.cs because it only looks for the PhysicsController, not the PhysicsControllerBehavior.  Also, I am seeing now that your camera classes all assume that the target is a physics object of some sort (rather than a point in the scene).  I'm thinking maybe that I might need to build my own camera system to do what I need.

Sep 28, 2009 at 6:41 PM
Edited Sep 28, 2009 at 6:42 PM

Yeah, Behaviors and User Controls are meant to be used independently, not mixed together. (the Physics User Controls were created back in Silverlight 2, before Behaviors existed).

If you look at CameraControllerMain, there is a TargetOverrideX and TargetOverrideY property which is meant to target a specific location on the playfield instead of an object. Unfortunately this is not exposed in the Behavior - but what you could do is get a reference to the CameraContollerMain object from the Behavior and tweak the properties directly.


Sep 28, 2009 at 6:55 PM

OK.  That's good to know.

I thought about doing what you descibed but a quick look at the camera code showed me that there's a lot that assumes we have a physics object target, and what I really need is a non-physics-object look-at point.  This helps, though.  Thanks!

BTW, does the parallax plane stuff work?  I don't see it in any demos.

Sep 28, 2009 at 7:05 PM

Yeah I used the parallax scrolling that's in there for Boss Launch -

I just haven't had time to clean it up and document, but it should at least be good for a base.

Sep 27, 2010 at 1:43 AM

Hey guys...

I am trying to do parallax scrolling on a basic side scrolling platformer.

Andy, can you explain the basics on how did you do it for BossLaunch?