locked
collisions RRS feed

  • Question

  • In silverlight how do I detect collisions between 2 objects or make this happen.

    I can move an object on a canvas around the screen.

    1)in vb.net there is a timer where you can use it to detect the position of objects and see if the are colliding. In silverlight there is no timer so what do i do?

    2)how do i move objects using keypress arrow keys?

    I am using vb.net
    Sunday, May 25, 2008 6:47 AM

Answers

  • That's correct, only PNG and JPG are supported. Use the Image control to display images. 

    Monday, May 26, 2008 12:54 PM
  • I love the Faseers physics engine, but you don't need it to detect simple object collisions. The best way is to use a DispatcherTimer and test the object moving against all objects in its path. Make sure to be predictive and test before the object has overlaped another. Check out my blog entries on collision detection. http://joel.neubeck.net/tag/collision
    Monday, May 26, 2008 4:48 PM

All replies

  • KeyDown += new KeyEventHandler(BSet_KeyDown);

            void BSet_KeyDown(object sender, KeyEventArgs e)
            {
                swtich(e.Key)
                    case Key.Left:
                       target.SetValue(UIElement.Canvas.LeftProperty, target.GetValue(UIElement.Canvas.LeftProperty) - 1;)
                    break;
                    case.....{for other case}
            }

    I dont know how to type it in VB but you can search in msdn
    But the Structure is like mine.

    # Target is a UIElement , therefore it can be rectangle or button or textbox... etc
    # In silverlight, you can use timer, read example here

    http://adoguy.com/2007/05/15/Silverlight_and_Timers.aspx

    Sunday, May 25, 2008 7:42 AM
  • In silverlight how do I detect collisions between 2 objects or make this happen.

    I can move an object on a canvas around the screen.

    1)in vb.net there is a timer where you can use it to detect the position of objects and see if the are colliding. In silverlight there is no timer so what do i do?

    I am using vb.net
     

    There is a System.Windows.Threading.DispatcherTimer in Silverlight.

    Sunday, May 25, 2008 10:52 AM
  • If you want collision detection then you probably need a physics engine. I suggest looking at the FarseerPhysics engine, which is fully open source and supports both WPF and Silverlight 2.0. You can get it from Codeplex at http://www.codeplex.com/FarseerPhysics


     

    Sunday, May 25, 2008 11:14 PM
  • To store images in SL is there an image control  or something ?

    It says you can only use PNG files as jpg and gif are not supported .

     

    Monday, May 26, 2008 2:57 AM
  • That's correct, only PNG and JPG are supported. Use the Image control to display images. 

    Monday, May 26, 2008 12:54 PM
  • I love the Faseers physics engine, but you don't need it to detect simple object collisions. The best way is to use a DispatcherTimer and test the object moving against all objects in its path. Make sure to be predictive and test before the object has overlaped another. Check out my blog entries on collision detection. http://joel.neubeck.net/tag/collision
    Monday, May 26, 2008 4:48 PM