Solved

farseer physics and problems

Posted on 2010-09-16
5
641 Views
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

http://www.andybeaulieu.com/silverlight/3.0/physicshelper3/index.htm
0
Comment
Question by:jagguy
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

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

http://www.dotnetspark.com/kb/1464-behavior-silverlight-30-tutorial.aspx

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()

            MyBase.OnAttached()



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



            AddHandler ad.MouseEnter, _

                Sub()

                    Dim p As PlaneProjection = Nothing



                    If ad.Projection Is Nothing Then

                        p = New PlaneProjection

                        ad.Projection = p

                    Else

                        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)

                    Else

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

                        ad.Tag = oTimer



                        If p IsNot Nothing Then

                            AddHandler oTimer.Tick, _

                                Sub()

                                    p.RotationZ += 1

                                End Sub

                        End If

                    End If



                    If oTimer IsNot Nothing Then oTimer.Start()

                End Sub



            AddHandler ad.MouseLeave, _

                Sub()

                    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

0
 

Author Comment

by:jagguy
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
0
 
LVL 7

Expert Comment

by:vbigham
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)" ??
0
 

Author Comment

by:jagguy
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?

http://www.mymrt.net/Gaming/Default.aspx
0
 
LVL 7

Accepted Solution

by:
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?

http://www.shinedraw.com/animation-effect/flash-vs-silverlight-simple-game-system/
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.3.0.0.5\Common\PhysicsHelper\obj\Debug
Select the file Spritehand.FarseerHelper.dll
You should be able to just click OK and then get:

PhysicsController
PhysicsJoint
PhysicsController
CameraLayer
PhysicsStaticHolder

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?
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Many programs have tried to outwit PowerPoint in terms of technology and skill. These programs, however, still lack several characteristics that PowerPoint has possessed from the start. Here's why PowerPoint replacements won't entirely work for desi…
Add visuals to your Prezi to keep your audience engaged. Learn how to embed images, edit them, and more in this video micro tutorial. Select "Insert" from the top menu in your Prezi editor: Select "Image": A toolbar will pop in from the right …
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. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

707 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

13 Experts available now in Live!

Get 1:1 Help Now