1

Currently I am drawing all of my elements using Win2d. I have read this in regards to Win2d here:

Win2D is a graphics API rather than a complete all-in-one game engine, but you could certainly use it to implement the graphics portion of a 2D game, in combination with other APIs for other areas such as input, sound, physics if your game needs that, etc.

I have looked into Box2d (which would be preferred because our Android app is using Box2d). But when I use Nuget to install Box2d I get Package restore failed. Rolling back to package changes for ....

I also have seen on Box2d's site that there is a port called Farseer Physics Engine. I get the same issues with with this as Box2d.

Then looking around even more I found Physics Helper XAML and ran the code. This is pretty close to what we want but setting it up in a existing app seems pretty cryptic. This uses Farseer Physics and it runs in the simulator just fine.

I develop primarily Mac and Android apps, so I am new territory running Visual Studio and developing in the windows environment. Also a lot of the documentation seems outdated.

Basically I am wondering what would be best for adding physics to my UWP and if I haven't covered another solution I should be exploring here I would love to hear about it.

Riley Bracken
  • 5,959
  • 2
  • 16
  • 17

1 Answers1

1

Farseer Physics Engine is not available for UWP Project. But Physics Helper XAML has already modified the source code to make it available for UWP App. So the fastest and easiest way to add Physics into your UWP App is to add the source code of Farseer Physics in Physics Helper XAML to your project.

You can achieve this by the following steps:

  1. Create a new blank UWP Project under VS->File->New->Project->Templates->Visual C#->Windows->Universal->Blank App(Universal Windows).
  2. Copy the FarseerPhysics Project into your UWP Project Folder. Redirect to the root folder of Physics Helper XAML, copy FarseerPhysics Folder into the root folder of your newly created UWP Project.
  3. Add the copied FarseerPhysics Project into your UWP Project. Right click Solution->Add->Existing Project->FarseerPhysics Folder that you copied->FarseerPhysics.csproj.
  4. Reference the FarseerPhysics into your UWP Project. Right Click References of your UWP Project in Solution Explorer->Add Reference->Projects->solution->FarseerPhysics.

And now you can use the FarseerPhysics in your UWP Project. You can using the same steps to add reference to PhysicsHelper in Physics Helper XAML, if you want.

And here is the basic empty UWP App with Physics that I made: EmptyUWPWithFarseer.

Elvis Xia - MSFT
  • 10,801
  • 1
  • 13
  • 24
  • Thanks for the answer, it worked like a charm. However on the 2nd step I didn't have to "Redirect to the root folder of Physics Helper XAML" – Riley Bracken Jul 06 '16 at 22:22
  • The Physics Helper XAML is very helpful, but only support mouse click. Do you know how to change it to support multitouch? – quangkid Dec 04 '17 at 03:31