Java tutorial
/* * This file is part of HackNet * Copyright (C) <2014> <Ivan Kulikov> * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package free.hacknet.game; import com.badlogic.gdx.Application; import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Screen; import com.badlogic.gdx.graphics.FPSLogger; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import free.hacknet.game.earth3d.mainTestEarthScreen; public class HackNetMain extends ApplicationAdapter { private SpriteBatch batch; private Screen curScreen; // the current screen private FPSLogger fpsLogger; private static HackNetMain instance = new HackNetMain(); private HackNetMain() { } public static HackNetMain getInstance() { return instance; } @Override public void create() { Gdx.app.setLogLevel(Application.LOG_DEBUG); Assets.init(); fpsLogger = new FPSLogger(); this.setCurScreen(new mainTestEarthScreen()); } @Override public void resize(int width, int height) { if (curScreen != null) curScreen.resize(width, height); } @Override public void render() { fpsLogger.log(); if (curScreen != null) curScreen.render(Gdx.graphics.getDeltaTime()); } @Override public void pause() { if (curScreen != null) curScreen.pause(); } @Override public void resume() { if (curScreen != null) curScreen.resume(); } @Override public void dispose() { curScreen.dispose(); } public void setCurScreen(Screen s) { if (this.curScreen != null) { this.curScreen.hide(); this.curScreen.dispose(); } this.curScreen = s; this.curScreen.show(); } }