MouseInput Problem

Hi folks,



i've a problem with mouseinput and special when i switch absolute->relative->absolute mouse. Here the details:



At the start of my game you can select the level you want to play by clicking on a self-written UIButton



// Mouse over the button

MouseInput.get().getXAbsolute()>=posx && MouseInput.get().getYAbsolute()>=posy &&

MouseInput.get().getXAbsolute()<=posx+width && MouseInput.get().getYAbsolute()<=posy+height



if (MouseInput.get().isButtonDown(0)){

  // Action

}



now the level starts. when you killed enough you go back to mainmenu.



At this point MouseInput.get().isButtonDown(0) is true already, even if you dont push the mousebutton, and the level starts again.

i include a delay between entering the menu and starting eventhandling. clicking anywhere at the menu reset MouseInput.get().isButtonDown(0) to valid values.



is there a workaround to fix the problem ?



peter

I would have the UIButton implement MouseInputListener and create an interface UIButtonListener that you can implement to listen to UIButtonPressedEvents.

Rik said:

I would have the UIButton implement MouseInputListener and create an interface UIButtonListener that you can implement to listen to UIButtonPressedEvents.


you are right but my project deadline ends in two days and there is a lot of other things to do (= is there any quick trick ?

Perhaps something like this?:




if (MouseInput.get().isButtonDown(0)&&buttonReleased){

Rik said:

Perhaps something like this?:



if (MouseInput.get().isButtonDown(0)&&buttonReleased){

GENIUS!!!  :smiley: