• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Motion listener hangs while mouse button is pressed

 
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am making a simple space shooter where you use the mouse to move and shoots with the mouse button. I am having trouble with the motion listener i.e the one that listens to mouse movement. When I press the left mouse button and hold it down the motion listener stops responding. The code for the listeners is below.



When I fire(clicking my left mouse button) I can�t move the ship while the button is pressed. I guess there is some kind of conflict between the two listeners but how do I fix this?
 
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the mouse button is held down while the mouse is being moved, it is no longer a mouseMoved event - it is a mouseDragged event. Put you movement code in mouseDragged as well and it should work fine.
 
Unnar Björnsson
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks alot
 
What's brown and sticky? ... a stick. Or a tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic