在这段代码中,我试图创建类的全局实例,以便任何方法都可以使用它:
public static void clip(){
while(!Display.isCloseRequested()){
glClear(GL_COLOR_BUFFER_BIT);
if(character.gravity)character.y++; //there is an error, it says "Variable character does not exist"
Display.update();
Display.sync(70);
}
}
public static void initGame(){
entity character = new entity(); // I want to use this in method clip()
character.create(true, "box", true);
}
我搜索了谷歌,但在我的问题“使类的实例全局化”中一无所获。感谢帮助。