locked
Collision detection RRS feed

  • Question

  • Hi, I just created a really simple animation, while I'm trying to understand how does the XNA Game Development works. It works amazingly great! However, now I'm trying to measure when is the Sprite collide with the side of the window and I expect it to bounce. Is there anything from the framework to measure the window size? thx... Smile And, can we change the window size, etc?
    Tuesday, April 3, 2007 7:17 PM

Answers

  • To get the size of the window, use "graphics.GraphicsDevice.Viewport.Width" and "graphics.GraphicsDevice.Viewport.Height"   (where graphics is the name of your GraphicsDeviceManager).

     

    You can change the size of your window by using the below statements in "public Game1()" under the initization of the GraphicsDeviceManager.

     

    Code Snippet

    graphics.PreferredBackBufferHeight = 900;

    graphics.PreferredBackBufferWidth = 900;

     

     

    Hope this helps.

    Wednesday, April 4, 2007 11:21 AM

All replies

  • To get the size of the window, use "graphics.GraphicsDevice.Viewport.Width" and "graphics.GraphicsDevice.Viewport.Height"   (where graphics is the name of your GraphicsDeviceManager).

     

    You can change the size of your window by using the below statements in "public Game1()" under the initization of the GraphicsDeviceManager.

     

    Code Snippet

    graphics.PreferredBackBufferHeight = 900;

    graphics.PreferredBackBufferWidth = 900;

     

     

    Hope this helps.

    Wednesday, April 4, 2007 11:21 AM
  • Work by example, I say.

    Check out Bill Riess's tutorials on XNA101.net for a good 3D example ofa game with 3D collision.

    For 2D check out XNAtutorials.com, the 2D tile engine is also very good.

     

    Hope this helps

    Darkside

    Wednesday, April 4, 2007 2:01 PM