XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

Coordinate system change at each run

Last post 26/06/2009 9:02 by Cinosura. 3 replies.
  • 25/06/2009 15:19

    Coordinate system change at each run

    Hello everyone,

    I realized a 3d scene with networking support. I would like to detect collision amoung object and mouse using Ray Class. Each time I run the game the collision detection happened in different coordinates even if I pointed to the same point. Then I made the application draws mouse position and I discovered the it change everytime I launch the game. the 2d coordinates system doesn't start always from the top-left vetex of the window.

    There's the way to define the start point of the 2d reference system so that I can fixed it each time i launch the game?

    thanks anyone could help me.

    Bye
  • 25/06/2009 16:52 In reply to

    Re: Coordinate system change at each run

    I'm going to assume you are using XNA in a WinForm, but you haven't given enough information to know for sure if that is true.

    If so, you need to set the Mouse.WindowHandle property to your game window handle (maybe Game.Window.Handle, I can't remember offhand). Also see this thread for issues when you open and close dialogs.
    www.dadoogames.com
    Curling 2010 - in playtest soon, this month or next, this year for sure (maybe)
  • 26/06/2009 7:45 In reply to

    Re: Coordinate system change at each run

    Hi, thanks for reply!
    I'm not using a winform, this problem happens into main window game. Each time I run the game, the origin of mouse coordinates system changes. For example, if I make the program write a string in mouse position it alwayes appear with a different offset related to cursor pointer, even if I don't set any offset.

    I tried to use Mouse.WindowHandle but nothing changed!

    Ayway If I remove networking it works properly (but iI can't because I need it!). Any other suggestion?
  • 26/06/2009 9:02 In reply to

    Re: Coordinate system change at each run

    Hello, I solved the problem

    just put:

    Mouse.WindowHandle = this.Window.Handle;

    at the beginning of Update cicle!

Page 1 of 1 (4 items) Previous Next