Interface Scene

  • All Superinterfaces:
    java.lang.Iterable<Actor>
    All Known Implementing Classes:
    World

    public interface Scene
    extends java.lang.Iterable<Actor>
    Scene with a map for the actors to act on.

    Implements iterator over the collection of scene actors.

    • Method Detail

      • getGame

        @NotNull
        @NotNull Game getGame()
        Returns:
        a game this scene belongs to.
      • getName

        @NotNull
        @NotNull java.lang.String getName()
        Returns:
        name of the scene
      • getMap

        @NotNull
        @NotNull SceneMap getMap()
        Returns:
        map representing the scene's environment.
      • getCamera

        @NotNull
        @NotNull com.badlogic.gdx.graphics.OrthographicCamera getCamera()
        Returns:
        camera used to render the view of the scene.
      • isInitialized

        boolean isInitialized()
        Gets initialization state of the scene.
        Returns:
        true when the scene was initialized already, false otherwise
      • getInput

        @NotNull
        @NotNull Input getInput()
        Gets input processor with listeners specific for the scene.
        Returns:
        scene input processor
        See Also:
        Game.getInput()
      • getMessageBus

        @NotNull
        @NotNull MessageBus getMessageBus()
        Returns:
        scene message bus
      • getListeners

        @NotNull
        @NotNull java.util.List<SceneListener> getListeners()
        Returns:
        scene lifecycle listeners
      • getActorFactory

        @Nullable
        @Nullable ActorFactory getActorFactory()
        Returns:
        factory used to construct actors loaded from the map.
      • getActors

        @NotNull
        @NotNull java.util.List<Actor> getActors()
        Returns:
        list of all actors currently in the scene
      • getActions

        @NotNull
        @NotNull java.util.List<Action<?>> getActions()
        Returns:
        list of all actions currently scheduled on some actor.
      • getOverlay

        @NotNull
        @NotNull Overlay getOverlay()
        Returns:
        scene overlay
      • init

        void init​(@NotNull
                  @NotNull Game game)
        Performs scene initialization
        Parameters:
        game - the game this scene belongs to.
      • addListener

        @NotNull
        @NotNull Disposable addListener​(@NotNull
                                        @NotNull SceneListener listener)
        Adds listener that can respond to scene's lifecycle events.
        Parameters:
        listener - the listener to add.
        Returns:
        disposable object that can be used to unregister listener.
      • addActor

        void addActor​(@NotNull
                      @NotNull Actor actor)
        Adds actor to the scene.
        Parameters:
        actor - actor to add.
      • removeActor

        void removeActor​(@NotNull
                         @NotNull Actor actor)
        Removes actor from the scene.
        Parameters:
        actor - actor to remove.
      • addActor

        default void addActor​(@NotNull
                              @NotNull Actor actor,
                              int posX,
                              int posY)
        Adds actor to the scene at [posX, posY] coordinates.
        Parameters:
        actor - actor to add
        posX - x position of actor
        posY - y position of actor
      • setActorRenderOrder

        void setActorRenderOrder​(@NotNull
                                 @NotNull java.util.List<java.lang.Class<?>> actorClasses)
        Defines order of actor types used to sort actors prior to rendering. It works according to the following rules:
        1. Actor of type with higher index is rendered on top of actor of type with lower index.
        2. The most specific type matching an actor is always selected.
        3. Actors not matching any one of here specified types are rendered below matched actors.
      • scheduleAction

        @NotNull
        @NotNull Disposable scheduleAction​(@NotNull
                                           @NotNull Action<?> action)
        Schedules action to be executed on the scene (with no specific actor).
        Parameters:
        action - action to schedule.
        Returns:
        Disposable object that can cancel the action.
      • scheduleAction

        @NotNull
        <A extends Actor> @NotNull Disposable scheduleAction​(@NotNull
                                                             @NotNull Action<A> action,
                                                             @NotNull
                                                             A actor)
        Schedules action to be executed on actor.
        Type Parameters:
        A - the type of actor.
        Parameters:
        action - action to schedule.
        Returns:
        Disposable object that can cancel the action.
      • cancelActions

        void cancelActions​(@NotNull
                           @NotNull Actor actor)
        Cancels all actions associated with given actor.
      • getFirstActorByName

        @Nullable
        default @Nullable Actor getFirstActorByName​(@NotNull
                                                    @NotNull java.lang.String name)
        Returns:
        first actor that has the given name, or null, if no such actor is found.
      • getLastActorByName

        @Nullable
        default @Nullable Actor getLastActorByName​(@NotNull
                                                   @NotNull java.lang.String name)
        Returns:
        last actor that has the given name, or null, if no such actor is found.
      • getFirstActorByType

        @Nullable
        default <A extends Actor> A getFirstActorByType​(@NotNull
                                                        @NotNull java.lang.Class<? extends A> cls)
        Returns:
        first actor that has the given type or null, if no such actor is found.
      • getLastActorByType

        @Nullable
        default <A extends Actor> A getLastActorByType​(@NotNull
                                                       @NotNull java.lang.Class<? extends A> cls)
        Returns:
        last actor that has the given type, or null, if no such actor is found.
      • centerOn

        void centerOn​(int x,
                      int y)
        Centers the scene's camera on the [x, y] point.
      • follow

        void follow​(@NotNull
                    @NotNull Actor actor)
        Starts to following actor with the camera.
        Parameters:
        actor - actor that should remain centered in the camera's view.
      • stopFollowing

        void stopFollowing()
        Stops the camera from following actors.
      • show

        void show()
        Shows the scene.
      • render

        void render​(float deltaTime)
        Renders the scene.
        Parameters:
        deltaTime - time passed from the previous render.
      • resize

        void resize​(int width,
                    int height)
        Resizes the scene to new dimensions.
        Parameters:
        width - new scene width
        height - new scene height
      • hide

        void hide()
        Hides the scene.
      • dispose

        void dispose()
        Disposes the scene resources.