Hey Andy, this is Jared Bienz with Microsoft. First I want to say that I'm a huge fan of the library. I've taught a few small Windows Phone gaming courses recently and students absolutely LOVE it.
I'm working on a sample like what you blogged about here:
In fact I'm trying to create a behavior that could easily be added to any application called the
PhysicsAccelerometerGravityBehavior. I'm sure you can imagine what it does, but I also want to add code to deal with the User Idel timeout problem in accelerometer games.
Everything is pretty much wrapped up, but I'm having a problem with the physics engine. My gut feel it has nothing to do with the Blend behaviors so I may need to consult the Farseer team, but I wanted to check with you first.
The problem is with updating physicsController.Simulator.Gravity property on acceleromer reading changed. It updates fine for several seconds but eventually the simulation locks. Not the app, just the simulation. If I have a timer on the screen the
timer keeps ticking and the accelermeter changed event keeps firing, but the simulation halts. It seems this happens when the accelerometer isn't moving much. Like if I set the phone down on a table and several updates to the Gravity property are made using
close numerical values. If I keep moving the phone around I can't seem to make it halt.
I thought I was doing something wrong until I found your blog post above and downloaded your sample. My code does almost exactly what yours does with a few small exceptions:
- With the new Farseer engine, physicsController.Simulator.Gravity.X and physicsController.Simulator.Gravity.Y cannot be set. Instead, you must set physicsController.Simulator.Gravity, which is a Vector2.
- The numbers I'm setting on physicsController.Simulator.Gravity are significantly smaller, also because of the engine change (around 100 instead of 500).
- I'm not using the wrapper classes you showed for using the mouse as an option.
Other than that, the logic is the same.
If I run your sample with the old engine, the simulation never halts. It just keeps going on forever. I was hoping I might be able to send you my updated project and see if you could confirm this bug and if you know of a resolution. I realize
you may not have a phone to test with and I can't confirm if the issue happens in the emulator since I'm not using your wrapper. But here's the link:
If you'd like to contact me directly, please feel free to use my jbienz at microsoft dot com address.