I'm trying to get my head around scrolling a 2D map that uses a physics engine. If I was to launch a projectile, would I actually be applying the physics to the background images rather than the projectile itself? I'd like to keep the projectile at the center of the 'camera', but I'm not sure how to do this in Silverlight. I thought of using a translate transform to constantly scroll the parent canvas's position, but is this the best way of doing this in Silverlight?

Edit - I'm using Farseer Physics with the Physics Helper library.

*Edit 2 - Solution *

It turns out the MSI installer of the Physics Helper installs an older version that had a broken camera. I downloaded and recompiled the latest source version and it now works!

  • 1
    \$\begingroup\$ What physics engine are you using? Did you write your own, or are you trying to decide which one to use? \$\endgroup\$ – Nate Apr 2 '11 at 18:12
  • \$\begingroup\$ I'm using Farseer. \$\endgroup\$ – Skoder Apr 2 '11 at 18:20
  • \$\begingroup\$ With the Physics Helper library. physicshelper.codeplex.com) \$\endgroup\$ – Skoder Apr 2 '11 at 18:36

I would suggest you go with a 2D engine that can help you do this. I use FlatRedBall personally, and initially it did have the capability to focus the camera on a single object regardless of that object's velocity or acceleration. (I believe it still does, but I haven't tried this recently.)

Applying forces to all background sprites is not a good idea; you should mimic the natural approach, which is to apply physics on the bullet.

I'm also making a 2D map game in Silverlight, but I haven't reached this point yet due to other constraints. It shouldn't be hard, given a good engine. FRB is good because it handles both graphics and physics simultaneously.

  • \$\begingroup\$ I'm using Farseer with the Physics Helper. Not sure if you've had much experience with it, but I'm trying to use its camera class (just found out about it). However, I'm having trouble keeping the target element in the center as it just moves off screen whilst the camera only moves very very slightly in the right direction (but doesn't keep up). \$\endgroup\$ – Skoder Apr 2 '11 at 18:21
  • \$\begingroup\$ I've heard of Farseer. It interoperates with FRB. Can't say I've used it though; sorry. \$\endgroup\$ – ashes999 Apr 2 '11 at 21:39
  • \$\begingroup\$ No problem. I should've mentioned the physics engine in my original question. \$\endgroup\$ – Skoder Apr 2 '11 at 22:06
  • \$\begingroup\$ Awesome. If you're not 100% locked in, I would say give FRB a try. It's pretty good; but the tools are mediocre in my estimation. \$\endgroup\$ – ashes999 Apr 2 '11 at 23:08

Whoops! Turns out the MSI installer installs an older version that had a broken camera. I downloaded and recompiled the latest source version and it now works!

  • \$\begingroup\$ You should add this as a comment to your original post. \$\endgroup\$ – ashes999 Apr 4 '11 at 1:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.