Skip to content

ExampleScene

da772 edited this page Feb 27, 2020 · 7 revisions

Creating a Scene

To create a new scene all you have to do is create a class that extends the Scene class. After this class it is automatically added to the scene manager. All you have to do is set it as the active scene to see it.

TestScene.java

package application;

import engine.CameraController;
import engine.Events.Event;
import engine.Scene;

public class TestScene extends Scene {

	public TestScene(String name, CameraController cam) {
		super(name, cam);
	}

        // Called every frame
	@Override
	public void OnUpdate(float deltaTime) {	
	}

        // Called once scene has become active
	@Override
	public void OnBegin() {
	}

        // Called once scene is no longer active
	@Override
	public void OnEnd() {
		
		
	}
       
        // Called when an event is triggered
	@Override
	public void OnEvent(Event e) {
		
		
	}
}

Adding a scene

TestApplication.java

 CameraController camera
        @Override
	protected void OnInit() {
		System.out.println(title+" Init!");
                camera = new CameraController.Orthographic(16.f/9.f); // The orthographic camera controller
                                                                      // takes in an aspect ratio

               new TestScene("TestScene", camera);        // Create Scene with a unique identifier of TestScene
               SceneManager.SetCurrentScene("TestScene");  // Set TestScene as the currently active scene
	}

Previous | Next

Clone this wiki locally