farseer physics and problems

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

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

jagguyAuthor Commented:
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
"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)" ??
jagguyAuthor Commented:
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?

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?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.