Hiding the lines that appear when moving objects...

Feb 11, 2011 at 5:26 AM
Edited Feb 11, 2011 at 5:27 AM


I just started playing around with PhysicsHelper and it's awesome! Amazing how easy it is to incorporate physics behavior in simple scenarios.

I am trying to get a hang of it by experimenting on PhysicsHelper for Windows Phone 7. I noticed that whenever I move the objects or drag them around, a line appears. Is there way to disable these lines from appearing?

I searched the discussions here, and on Farseer too, but couldn't find anything useful. I know it's probably a matter of setting a flag or something, right?



Feb 11, 2011 at 11:27 AM

What a coincidence. I had just come to the forums to find an answer for this myself, and lo and behold - there's your post staring right at me!

Having a look at the source code (./Common/PhysicsHelper/PhysicsControllerMain.cs to be exact), _lineShowSpring appears to be set as visible, with no options of turning this off.

I've tried importing PhysicsControllerMain.cs and editing it myself (like I did with CameraControllerMain earlier), but I wasn't able to grab the PhysicsControllerMain object after that.

Maybe if we search through the entire game canvas for the line in some smart way, and make sure it's collapsed?

Feb 11, 2011 at 11:46 AM

I've got a quick workaround. I just added a handler for the Physics Controller's mouse move event as so:

pc = cnvGame.GetValue(PhysicsControllerMain.PhysicsControllerProperty) as PhysicsControllerMain;    
pc.MouseMove += new PhysicsControllerMain.MouseMoveHandler(touchMove_MainMenu);

So while the mouse (touch) is 'moving', the line can be found and it's visibility overridden:

void touchMove_MainMenu(string sprite)
    foreach (UIElement uiElement in cnvGame.Children)
        if (uiElement.GetType().Name == "Line")
            uiElement.Visibility = System.Windows.Visibility.Collapsed;

Note that this only works for me because I've got not other Line UIElements in the game canvas. If you do utilize other Lines, you'd have to rule these out to find the physic's controller's one.

Also, I realize that going through the entire UIElementCollection to find this particular line is probably the least efficient way to do it, but I've got no other ideas at the moment.

Feb 11, 2011 at 11:54 AM

By the way, you might want to add that foreach loop to the Physics Controller's 'Mouse Down' event as well. I noticed that the line appears briefly on some occasions.

Feb 14, 2011 at 12:47 PM
Edited Feb 14, 2011 at 12:47 PM

Thanks Arkuana, this works. But I think checking every UIElement in every mouse down and mouse move event might have some hit on performance, do you think?

I am thinking of compiling Physics Helper after setting "_lineShowSpring" to false; I'll try and update here, hopefully it will work.

Edit: btw, did you try compiling?



Mar 11, 2011 at 5:19 PM


you have to disable the Visibility of the _lineShowSpring instead of removing it.

I just added a new boolean Property "ShowMouseLineSpring". With help of that you can keep the line from being made visible (Lines 793 and 847) in PhysicsControllerMain.cs