All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.badlogic.gdx.Game Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright 2011 See AUTHORS file.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

package com.badlogic.gdx;

/** 

* An {@link ApplicationListener} that delegates to a {@link Screen}. This allows an application to easily have multiple screens. *

*

* Screens are not disposed automatically. You must handle whether you want to keep screens around or dispose of them when another * screen is set. *

*/ public abstract class Game implements ApplicationListener { private Screen screen; @Override public void dispose () { if (screen != null) screen.hide(); } @Override public void pause () { if (screen != null) screen.pause(); } @Override public void resume () { if (screen != null) screen.resume(); } @Override public void render () { if (screen != null) screen.render(Gdx.graphics.getDeltaTime()); } @Override public void resize (int width, int height) { if (screen != null) screen.resize(width, height); } /** Sets the current screen. {@link Screen#hide()} is called on any old screen, and {@link Screen#show()} is called on the new * screen. */ public void setScreen (Screen screen) { if (this.screen != null) this.screen.hide(); this.screen = screen; screen.show(); screen.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); } /** @return the currently active {@link Screen}. */ public Screen getScreen () { return screen; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy