Package game.scenes

Source Code of game.scenes.SplashScene

package game.scenes;

import engine.geometry.Vector;
import engine.hierarchy.DefaultScene;
import engine.interfaces.Clock;
import engine.interfaces.Image;
import engine.interfaces.Keyboard;
import engine.interfaces.Keyboard.Key;
import engine.interfaces.Mouse;
import engine.interfaces.RenderTarget;

public final class SplashScene extends DefaultScene {
    private Image image;
    private Vector position;
    private String imageName;

    public SplashScene(final String imageName) {
        this.imageName = imageName;
    }

    @Override
    public void onAdd() {
        getStage().getSceneBelow(this).setActive(false);
        image = getStage().getLibrary().findImage(imageName);
        position = new Vector(0, 0);
    }

    @Override
    public void onBeforeMove(final Keyboard keyboard, final Mouse mouse, final Clock clock) {
        if (keyboard.wasReleased(Key.VK_ESCAPE)) {
            getStage().getSceneBelow(this).setActive(true);
            getStage().removeScene(this);
        }
    }

    @Override
    public void onDraw(final RenderTarget target) {
        target.drawImage(image, position);
    }
}
TOP

Related Classes of game.scenes.SplashScene

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.