External classes positions don't work?

Posted by SystemNetworks on Game Development See other posts from Game Development or by SystemNetworks
Published on 2012-11-23T05:34:17Z Indexed on 2012/11/23 11:17 UTC
Read the original article Hit count: 205

Filed under:
|

I have an external class which reads the user's mouse clicks. I gave a position where the user have to click, and when the user clicks on that position, it would turn my boolean "mouse" to true. But when I connect that to my game(state based) class, it does not work.

Here's the code:

External class

public void UI(Input input, GameContainer gc, float posX, float posY)
    {
        int x = Mouse.getX();
        int y = Mouse.getY();
        if(posX<=100 && posY<=100)
        {
        if(Mouse.isButtonDown(1))
        {
            mouse = true;
        }
        }
    }

Game class(main)

public void update(GameContainer gc, StateBasedGame sbg, int delta)
            throws SlickException {
int x = Mouse.getX();
           int y = Mouse.getY();
                civ.UI(input, gc, x,y);
}

The problem is when I click my mouse at posX<=100 && posY<=100. It does not work.

© Game Development or respective owner

Related posts about java

Related posts about slick2d