Java tutorial
/* * Copyright (c) 2013 matheusdev * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package org.matheusdev.ror.screens; import com.badlogic.gdx.InputProcessor; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.utils.Disposable; import org.matheusdev.ror.RuinsOfRevenge; /** * @author matheusdev * */ public abstract class AbstractScreen implements Disposable, InputProcessor { protected final Stage stage; protected final RuinsOfRevenge game; public AbstractScreen(Stage stage, RuinsOfRevenge game) { this.stage = stage; this.game = game; } public void update(float delta) { if (game.shouldHaveInputFocus(this)) tick(delta); draw(stage.getSpriteBatch()); } public Stage getStage() { return stage; } public abstract void tick(float delta); public abstract void draw(SpriteBatch batch); public abstract void resize(int width, int height); public abstract boolean isParentVisible(); @Override public void dispose() { } @Override public boolean keyDown(int keycode) { return stage.keyDown(keycode); } @Override public boolean keyUp(int keycode) { return stage.keyUp(keycode); } @Override public boolean keyTyped(char character) { return stage.keyTyped(character); } @Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { return stage.touchDown(screenX, screenY, pointer, button); } @Override public boolean touchUp(int screenX, int screenY, int pointer, int button) { return stage.touchUp(screenX, screenY, pointer, button); } @Override public boolean touchDragged(int screenX, int screenY, int pointer) { return stage.touchDragged(screenX, screenY, pointer); } @Override public boolean mouseMoved(int screenX, int screenY) { return stage.mouseMoved(screenX, screenY); } @Override public boolean scrolled(int amount) { return stage.scrolled(amount); } }