User Tag List

Results 1 to 6 of 6

Thread: Mouse Direction

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Eliyahu's Avatar
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mouse Direction

    I was wondering if there was any possible way to know which direction the mouse is moving, like if you're going left, right, up or down. So is there a way to do it? If so, how?

    And I have already used the mouse object in a game, I made it so moving the mouse swings your sword, but now I want to be able to have different directions.

  2. #2
    Forum Moderator Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleSWF Export ModuleInstall Creator Pro
    Paul_Boland's Avatar
    Join Date
    Jun 2006
    Location
    Waterford, Ireland.
    Posts
    2,739
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Mouse Direction

    You could have an invisible object follow the mouse and based on what direction it is moving, will tell you what direction the mouse is moving.
    KnightTrek Productions
    http://www.knighttrek.com

  3. #3
    Clicker Fusion 2.5 DeveloperFusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleXNA Export Module
    DistantJ's Avatar
    Join Date
    Jan 2008
    Location
    Gloucester, UK
    Posts
    2,144
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: Mouse Direction

    There is the mouse object extension, which I believe can work out the speed of the mouse movement. Possibly the direction, I'm not sure.

    Personally I'd just keep two values, current mouse position and previous mouse position. Store the mouse position in two values (one for X one for Y), then when the mouse moves, store those previous values elsewhere as the previous position, and overwrite the original values with the new position, then you can compare them, for example if the 'previous mouse Y position' value is lower than the 'current mouse Y position' value, you know that it has moved upwards, etc...

    Sorry if that's a little advanced.

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Eliyahu's Avatar
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Mouse Direction

    DistantJ, that is actually what I tried, but it is set on a timer, so sometimes it lags, yet I don't want it so fast that the slightest movement sets it off.

    Having an invisible object works great! Thanks!

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleXNA Export Module
    DistantJ's Avatar
    Join Date
    Jan 2008
    Location
    Gloucester, UK
    Posts
    2,144
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: Mouse Direction

    Glad the invisible object method worked for you. As for your first method, I'd have perhaps used a counter rather than the timer, then if it lags, the counter lags with it and so it doesn't miss anything.

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Eliyahu's Avatar
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Mouse Direction

    I don't really know how you could use a counter, the timer was just quicker to set up. The invisible object is really good, and now i can get the good diagonals I want. It's really useful in my newest game, a tennis game where you swing the racquet to hit the ball in time. I'm also think about having the raquet aim at your mouse so you actually swing. I'll see which moves smoother. However this mouse movement will be extremely useful in future games.

Similar Threads

  1. Fine Direction on mouse shooters
    By diefox in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 17th October 2012, 06:26 AM
  2. mouse n direction n speed or turning n what not
    By gordonquinton11 in forum The Games Factory 2 - Technical Support
    Replies: 5
    Last Post: 28th September 2011, 02:54 AM
  3. I need to detect the direction the mouse is moved
    By Tuna in forum SWF/Flash Export Module Version 2.0
    Replies: 6
    Last Post: 6th September 2010, 07:14 PM
  4. Shooting something in the direction of the mouse?
    By Root in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 21st May 2009, 10:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •