farseer physics and problems

Posted on 2010-09-16
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this Micro Tutorial viewers will learn the basic shortcuts and functions of Illustrator. The viewer will learn about the paintbrush tool, anchor points, font sizing, and more.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Suggested Courses

719 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