farseer physics and problems

Posted on 2010-09-16
Last Modified: 2013-11-12
Can I use farseer physics and silverlight with bitmap images only (no Blend)?

I dont want Blend at all as this limits the graphics and i would also need to fork out $300 for it and no I dont want the trial.

The examples I see use Blend to create the graphics/Behaviours so it seems Blend is in integral part
Question by:jagguy
  • 3
  • 2

Expert Comment

ID: 33698824
Behaviors can also be added in code/xaml using visual studio.  There is an example at this link:

And here is a behavior that I created in VB.NET(sorry) and added to some different controls to make them spin (I am hoping that those farseer behaviors can also be added to any framework element).. The xaml for my example was nearly the same as that in the dotnetspark article.
Namespace MyBehaviors

    Public Class RotationBehavior

        Inherits Behavior(Of DependencyObject)

        Protected Overrides Sub OnAttached()


            Dim ad As FrameworkElement = CType(Me.AssociatedObject, FrameworkElement)

            AddHandler ad.MouseEnter, _


                    Dim p As PlaneProjection = Nothing

                    If ad.Projection Is Nothing Then

                        p = New PlaneProjection

                        ad.Projection = p


                        p = TryCast(ad.Projection, PlaneProjection)

                    End If

                    Dim oTimer As DispatcherTimer = Nothing

                    If ad.Tag IsNot Nothing AndAlso TypeOf ad.Tag Is DispatcherTimer Then

                        oTimer = DirectCast(ad.Tag, DispatcherTimer)


                        oTimer = New DispatcherTimer With {.Interval = TimeSpan.FromMilliseconds(1)}

                        ad.Tag = oTimer

                        If p IsNot Nothing Then

                            AddHandler oTimer.Tick, _


                                    p.RotationZ += 1

                                End Sub

                        End If

                    End If

                    If oTimer IsNot Nothing Then oTimer.Start()

                End Sub

            AddHandler ad.MouseLeave, _


                    If ad.Tag IsNot Nothing AndAlso TypeOf ad.Tag Is DispatcherTimer Then

                        DirectCast(ad.Tag, DispatcherTimer).Stop()

                    End If

                End Sub

        End Sub

    End Class

End Namespace

Open in new window


Author Comment

ID: 33699214
I  dont want xaml and in code I want to use images and not usercontrols or Blend
This kind of defeats the purpose using substandard graphics to make it look better for a game.

A Behavior is in essence a reusable piece of interactivity that can be applied directly to user interface elements in Expression Blend.  

I think the answer is clearly NO.

I will just create my own routines and in time use Flex it appears my silverlight journey without limited 2D/3D support is coming to an end

Expert Comment

ID: 33702814
"Can I use farseer physics and silverlight with bitmap images only (no Blend)?"

I thought I just showed you that the answer is clearly YES.  But you do need some kind of control to host the image content (an Image, or Canvas control work well).  I looks like the farseer controls are required to be hosted inside a Canvas, but I don't think that UserControls are required.  You can add behaviors to any kind of control that you want (usercontrol, button, image, whatever).

"I  dont want xaml and in code I want to use images and not usercontrols or Blend"

Then don't do it.  But FYI UserControls and behaviors are not synonymous with Expression Blend.  They can be defined, modified and instantiated in xaml, OR code, OR both.  I prefer to use Visual Studio for Silverlight development because I work more with data and code, but I've talked to some people who prefer Blend, and some that even use both, and other tools for IDEs are available as well (eclipse and mono to name a couple).  There does seem to be an inflexibility with Silverlight and embedding .bmp files, it seems that it only wants .png or .jpg formats for the Image control source property in which case bitmaps may have to be loaded through code :(

I looked into the farseer libraries a little bit and it seems that their easiest use would be in Expression Blend 3.  However, I am able to reference those libraries and use them in Visual Studio without much difficulty.  These could be phenominally useful.  Thank you for bringing them back to my attention!  And the helper libs that Andy Beuelieu is demonstrating look nice (from your link).

"it appears my silverlight journey without limited 2D/3D support is coming to an end"
Silverlight has definitely not reached maturity, and has undergone many changes in each new version that has been released.  That being said, I wouldn't blame you for wanting to use a technology that has been around a while longer.

If you still think the answer to your first question is no, would you mind clarifying what you mean by "bitmap images only (no Blend)" ??

Author Comment

ID: 33706855
ok thanks for the post .
Let me explain a few things. Here some games I have already made .
Now I want better 2D/3D support and with 2D it seems HARD to get tutorials with farseer physics that only use images. Real games use images not user controls or things made with Blend as they do in Flash.

Do I stick with Silverlight or do I simply go with Flash/Flex. I get graphics made and in png format for silverlight and have no need for Blend. IN fact I dont like Blend. I like coding and .net seems much better than actionscript but I seem to be limited with SIlverlight.

Even if I found a way to use Farseer physics then where is the help/examples or others peoples games that are as good as Flash?

Accepted Solution

vbigham earned 500 total points
ID: 33708300
Good question and nice job on those games!

I am not able to find any decent tutorials either :(  Might have to figure it out for myself and write one?
Probably you have seen this one already, and I'm sure its not going to help you with Farseer..

Here's what I did in Visual Studio to add the farseer helper controls to my toolbox:
Right click an empty area in the toolbox (under the general tab usually works)
Click Add Tab, and give the new tab a name
Right Click the area inside the new tab and click Choose Items
Click Browse button, browse to ..\PhysicsHelper.\Common\PhysicsHelper\obj\Debug
Select the file Spritehand.FarseerHelper.dll
You should be able to just click OK and then get:


Right in your toolbox.

I don't know much about flex and flash, just that I didn't like it when I tried to use it.  Sorry that I'm not able to be of any meaningful assistance at the moment.  I am going to look at some of the source code and see if I can figure it out.  I'm pretty sure that anything you can do in blend you can do in visual studio.

Maybe some other experts can help us?

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Learn how to download your full Prezi presentation for offline presenting. Prezi doesn’t have to be viewed and shared in a web browser, even with a free account you can download your full presentation to share with others. Be sure to download any vi…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now