From inside the touchDown() function : how to access to variables defined in main() ?

azertix

New member
May 19, 2013
1
0
0
Visit site
Hi there !

I followed this tutorial https://code.google.com/p/libgdx/wiki/scene2d#InputListener :
Code:
actor.addListener(new InputListener() {
        public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
                System.out.println("down");
                return true;
        }
        
        public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
                System.out.println("up");
        }
});

When a button is pressed, I would like that an sql query is executed.

So i just added 2 lines inside the touchDown() function :
Code:
        public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
                System.out.println("down");
                db = new Database();
                scores = db.UpdateScore(myVariable);
                return true;
        }


But this won't compile because "myVariable" is not defined in the class, "myVariable" is defined in the main file.