Class Scene

java.lang.Object
io.github.espressoengine.Scene

public class Scene extends Object

Organizes and contains main JyGame components. Each scene contains a window and list of objects to draw, along with some extra functions.

Version:
$Id: $Id
Author:
pastthepixels
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor which creates a new Window.
    Scene(Window window)
    Constructor which uses a predefined Window.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(Object object)
    Adds an object to the scene (by adding it to a queue of objects to add to Scene.objects when the scene next updates).
    void
    process(double delta)
    Called every time the scene updates and is designed to be overridden (another function very inspired from Godot).
    void
    remove(Object object)
    Removes an object from the scene (by adding it to a queue of objects to remove from Scene.objects when the scene next updates).
    void
    Sets the background of a scene to a specified color.
    void
    Starts a new loop in which Scene.update() is called on a separate thread at 60 frames per second.
    void
    Updates the object list and redraws the canvas in the window attached to the scene.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Scene

      public Scene(Window window)

      Constructor which uses a predefined Window.

      Parameters:
      window - a Window object
    • Scene

      public Scene()

      Constructor which creates a new Window.

  • Method Details

    • add

      public void add(Object object)
      Adds an object to the scene (by adding it to a queue of objects to add to Scene.objects when the scene next updates).
      Parameters:
      object - a Object object
    • remove

      public void remove(Object object)
      Removes an object from the scene (by adding it to a queue of objects to remove from Scene.objects when the scene next updates).
      Parameters:
      object - a Object object
    • update

      public void update()
      Updates the object list and redraws the canvas in the window attached to the scene.
    • startLoop

      public void startLoop()
      Starts a new loop in which Scene.update() is called on a separate thread at 60 frames per second.
    • process

      public void process(double delta)
      Called every time the scene updates and is designed to be overridden (another function very inspired from Godot).
      Parameters:
      delta - a double
    • setBackground

      public void setBackground(Color color)
      Sets the background of a scene to a specified color.
      Parameters:
      color - a Color object