Multiple Mouse Listeners. Need help!

Hey again people, i hope my questions aren't to tiring, and thank you originalsup3rman for answering my last question. I didn't want to revive the thread for fear of annoying some random person.

On to the question.

I was just wondering the best way to go about having a MouseListener and a MouseMotionListener to operate at the same time. What i'm doing is, i'm moving a guy with the mouse (he follows the mouses position) then i need him to be able to shoot at the SAME time with the clicker. Right now whenever i'm currently moving the mouse i can't shoot, but i can shoot when the mouse isn't moving. OK so this is the way i'm doing it right now:

Player p;

publicclass GameThing{

public GameThing(){

p =new Player...

addMouseMotionListener(new Listener());

addMouseListener(new Listener());

...

...

}

...

...

...

publicclass Listenerimplements MouseListener, MouseMotionListener{

publicvoid mouseClicked(MouseEvent e){

p.addBullet();

}

publicvoid mouseEntered(MouseEvent e){}

publicvoid mouseExited(MouseEvent e){}

publicvoid mousePressed(MouseEvent e){}

publicvoid mouseReleased(MouseEvent e){}

publicvoid mouseDragged(MouseEvent e){

p.synch(e.getX(), e.getY());

}

publicvoid mouseMoved(MouseEvent e){

p.synch(e.getX(), e.getY());

}

}

...

...

...

}

(keep in mind this isn't my entire class, i'm only showing the parts pertaining to the problem ;D)

I know someone can answer my question quickly and painlessly, I'd REALLY appreciate a response, thanks again for being so helpful.

p.s. I'm heading off to work now as well so if you have a question about my code i'll be back at 10:00. :D

[3125 byte] By [PaRlOaGna] at [2007-11-27 9:58:54]
# 1
Have you tried moving the firing code to mousePressed?
PReida at 2007-7-13 0:29:48 > top of Java-index,Other Topics,Java Game Development...
# 2
You're a genius McFly!! Thanks alot man! see? i knew there was a simple answer lying around somewhere in my stupidity! Cannot thank you enough.
PaRlOaGna at 2007-7-13 0:29:48 > top of Java-index,Other Topics,Java Game Development...
# 3

In this example, you custruct 2 different listeners:

addMouseMotionListener(new Listener());

addMouseListener(new Listener());

Doesn't that kind of defeat the purpose of putting them in the same listener? Why not create one instance and add that to both?

robtafta at 2007-7-13 0:29:48 > top of Java-index,Other Topics,Java Game Development...