Package scene
Class Scene
java.lang.Object
scene.Scene
- Direct Known Subclasses:
DemoPlatformer
,DemoTopDown
,TextRenderingDemo
- Author:
- Asher Haun, Juyas, VoxelRifts
Abstract class encapsulating the game logic, the gameObjects, the renderers, the physics specifications and all the necessary ecs-related logic. Programming/Interacting with this game engine will usually involve the following boilerplate code:
public class Main extends Scene { public static void main(String[] args) { Engine.init(1920, 1080, "Azurite Engine Demo In Comment", 1.0f); Engine.scenes().switchScene(new Main(), true); Engine.showWindow(); } public void awake() { camera = new Camera(); ... } public void update() { ... } }
A simple example of a scene with just a rendered sprite:public class Main extends Scene { GameObject player; Sprite s; public static void main(String[] args) { Engine.init(1920, 1080, "Azurite Engine Demo In Comment", 1.0f); Engine.scenes().switchScene(new Main(), true); Engine.showWindow(); } public void awake() { camera = new Camera(); player = new GameObject(); s = new Sprite player.addComponent(new SpriteRenderer(s, new Vector2f(100))); } public void update() { if (Keyboard.getKeyDown(GLFW.GLFW_KEY_SPACE)) { player.transform.add(new Vector2f(1, 0)); } } }
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
This method will be called each time this scene becomes active bySceneManager
.void
addGameObjectToScene
(GameObject gameObject) void
addToRenderers
(GameObject gameObject) Add a gameObject to all renderersvoid
addUiObject
(Text t) void
awake()
Runs only once on startup, useful for initializing gameObjects or for first time setup.camera()
void
clean()
This method is called at the end of the programvoid
This method will be called each time this scene becomes inactive bySceneManager
, because of switching to another method or termination of the program.void
void
Initialize all renderersboolean
isActive()
void
postProcess
(Texture texture) Apply post processing to a texturefinal void
registerCollider
(GameObject gameObject) void
registerRenderer
(Renderer renderer) Register a renderer to this scenevoid
removeGameObjectFromScene
(GameObject gameObject) void
render()
final int
sceneId()
The sceneId is meant to represent the instance of a scene as an integerfinal void
Loops through all gameobjects already in the scene and calls their start methods.final void
startUi()
final void
final void
unregisterCollider
(GameObject gameObject) void
update()
This method is called every frame, and can be used to update objects.void
Loops through all the gameObjects in the scene and calls their update methods.void
updateUI()
-
Field Details
-
renderer
-
lightmapRenderer
-
debugRenderer
-
textRenderer
-
camera
-
forwardToScreen
-
-
Constructor Details
-
Scene
public Scene()
-
-
Method Details
-
isActive
public boolean isActive() -
awake
public void awake()Runs only once on startup, useful for initializing gameObjects or for first time setup. -
activate
public void activate()This method will be called each time this scene becomes active bySceneManager
. Will be called right before the first update. Can be used to prepare the scene to be shown after been shown previously to reset to a certain state. -
deactivate
public void deactivate()This method will be called each time this scene becomes inactive bySceneManager
, because of switching to another method or termination of the program. Can be used to preserve the current state of the scene or quickly complete/cancel tasks that were midst execution. -
update
public void update()This method is called every frame, and can be used to update objects. -
postProcess
Apply post processing to a texture- Parameters:
texture
- input texture
-
clean
public void clean()This method is called at the end of the program -
startUi
public final void startUi() -
startGameObjects
public final void startGameObjects()Loops through all gameobjects already in the scene and calls their start methods. -
getColliders
-
registerCollider
-
unregisterCollider
-
sceneId
public final int sceneId()The sceneId is meant to represent the instance of a scene as an integer- See Also:
-
getGameObjects
- Returns:
- the List of gameObjects contained in the scene.
-
addGameObjectToScene
- Parameters:
gameObject
- GameObject to be added. Add a new gameObject to the scene and immediately call its start method.
-
removeGameObjectFromScene
- Parameters:
gameObject
- GameObject to be added.
-
registerRenderer
Register a renderer to this scene- Parameters:
renderer
- the renderer to be registered
-
camera
- Returns:
- Returns the scene's instance of Camera
-
updateGameObjects
public void updateGameObjects()Loops through all the gameObjects in the scene and calls their update methods. -
render
public void render() -
debugRender
public void debugRender() -
initRenderers
public void initRenderers()Initialize all renderers -
addUiObject
-
textRender
public final void textRender() -
updateUI
public void updateUI() -
addToRenderers
Add a gameObject to all renderers- Parameters:
gameObject
- the gameObject to be added
-