com.altportalgames.colorrain.controller.Game.java Source code

Java tutorial

Introduction

Here is the source code for com.altportalgames.colorrain.controller.Game.java

Source

/*******************************************************************************
 * 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.altportalgames.colorrain.controller;

import com.altportalgames.colorrain.view.Screen;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;

public abstract class Game implements ApplicationListener {
    Screen screen;

    public abstract boolean needsGL20();

    public void setScreen(Screen helpScreen2) {
        System.out.println("set startscreen");
        screen.pause();
        screen.dispose();
        screen = helpScreen2;
    }

    public abstract Screen getStartScreen();

    @Override
    public void create() {
        System.out.println("game.create");
        screen = getStartScreen();
    }

    @Override
    public void resume() {
        System.out.println("game.resume");
        screen.resume();
    }

    @Override
    public void render() {
        //System.out.println("game.render");
        screen.update(Gdx.graphics.getDeltaTime());
        screen.present(Gdx.graphics.getDeltaTime());
    }

    @Override
    public void resize(int width, int height) {

    }

    @Override
    public void pause() {
        System.out.println("game.pause");
        screen.pause();
    }

    @Override
    public void dispose() {
        System.out.println("game.dispose");
        screen.dispose();
    }
}