Java Libgdx-在函数中使用void作为绘图

Java Libgdx-在函数中使用void作为绘图,java,android,libgdx,arguments,void,Java,Android,Libgdx,Arguments,Void,我想用void作为libgdx中的参数来创建一个void, 我如何让它工作 这就是我所拥有的: public class ReleaseDetector{ boolean Touched = false; // // --- Simple void for touch release detection, when looped. --- // --- and the argument void, or how i imagin

我想用void作为libgdx中的参数来创建一个void, 我如何让它工作

这就是我所拥有的:

public class ReleaseDetector{

        boolean Touched = false;

        //
        // --- Simple void for touch release detection, when looped. ---
        // --- and the argument void, or how i imagine it..
        //
        public void ReleaseListener(void MyArgumentVoid)//<---The argument void
        {
            if (Gdx.input.isTouched()){

                Touched = true;
            }
            if (!Gdx.input.isTouched() && Touched){
            MyArgumentVoid();<----------// Call for a void from the Argument.
            Touched = false;
            }
        }
}

现在,我该如何让它成为现实?我希望有一个简单的方法。

您似乎需要一个回调方法,它不接受任何参数并返回
void

public class ReleaseDetector {

    boolean touched = false;

    public void releaseListener(MyGdxGame game) { // Argument
        if (Gdx.input.isTouched()) {
            touched = true;
        }
        if (!Gdx.input.isTouched() && touched){
            game.addCounter();                    // Callback
            touched = false;
        }
    }
}


希望这能有所帮助。

您不希望使用void作为参数,您希望函数既没有返回也没有参数。您必须先学会遵循java命名约定,您是在用C之类的语言编写代码
public class ReleaseDetector {

    boolean touched = false;

    public void releaseListener(MyGdxGame game) { // Argument
        if (Gdx.input.isTouched()) {
            touched = true;
        }
        if (!Gdx.input.isTouched() && touched){
            game.addCounter();                    // Callback
            touched = false;
        }
    }
}
public class MyGdxGame extends ApplicationAdapter {

    int counter = 0;
    ReleaseDetector detector = new ReleaseDetector();

    public void addCounter() {
        counter++;
    }

    @Override
    public void render() { // Render Loop.
        detector.releaseListener(this);
    }
}