Class World

  • All Implemented Interfaces:
    java.lang.Iterable<Actor>, Scene

    public final class World
    extends java.lang.Object
    implements Scene
    • Field Detail

      • ACTOR_ADDED_TOPIC

        public static final Topic<Actor> ACTOR_ADDED_TOPIC
        Topic for actors added to the scene. Published to by the addActor(Actor) method.
      • ACTOR_REMOVED_TOPIC

        public static final Topic<Actor> ACTOR_REMOVED_TOPIC
        Topic for actors removed from the scene. Published to by the removeActor(Actor) method.
    • Constructor Detail

      • World

        public World()
      • World

        public World​(@Nullable
                     @Nullable java.lang.String name)
      • World

        public World​(@Nullable
                     @Nullable java.lang.String name,
                     @Nullable
                     @Nullable java.lang.String mapResource)
      • World

        public World​(@Nullable
                     @Nullable java.lang.String mapResource,
                     @Nullable
                     @Nullable ActorFactory actorFactory)
      • World

        public World​(@Nullable
                     @Nullable java.lang.String name,
                     @Nullable
                     @Nullable java.lang.String mapResource,
                     @Nullable
                     @Nullable ActorFactory actorFactory)
    • Method Detail

      • getName

        @NotNull
        public @NotNull java.lang.String getName()
        Specified by:
        getName in interface Scene
        Returns:
        name of the scene
      • getActorFactory

        @Nullable
        public @Nullable ActorFactory getActorFactory()
        Specified by:
        getActorFactory in interface Scene
        Returns:
        factory used to construct actors loaded from the map.
      • isInitialized

        public boolean isInitialized()
        Description copied from interface: Scene
        Gets initialization state of the scene.
        Specified by:
        isInitialized in interface Scene
        Returns:
        true when the scene was initialized already, false otherwise
      • getGame

        @NotNull
        public @NotNull Game getGame()
        Specified by:
        getGame in interface Scene
        Returns:
        a game this scene belongs to.
      • getOverlay

        @NotNull
        public @NotNull Overlay getOverlay()
        Specified by:
        getOverlay in interface Scene
        Returns:
        scene overlay
      • getMap

        @NotNull
        public @NotNull SceneMap getMap()
        Specified by:
        getMap in interface Scene
        Returns:
        map representing the scene's environment.
      • getCamera

        @NotNull
        public @NotNull com.badlogic.gdx.graphics.OrthographicCamera getCamera()
        Specified by:
        getCamera in interface Scene
        Returns:
        camera used to render the view of the scene.
      • getInput

        @NotNull
        public @NotNull Input getInput()
        Description copied from interface: Scene
        Gets input processor with listeners specific for the scene.
        Specified by:
        getInput in interface Scene
        Returns:
        scene input processor
        See Also:
        Game.getInput()
      • getActors

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

        @NotNull
        public @NotNull java.util.List<Action<?>> getActions()
        Specified by:
        getActions in interface Scene
        Returns:
        list of all actions currently scheduled on some actor.
      • getListeners

        @NotNull
        public @NotNull java.util.List<SceneListener> getListeners()
        Specified by:
        getListeners in interface Scene
        Returns:
        scene lifecycle listeners
      • getMessageBus

        @NotNull
        public @NotNull MessageBus getMessageBus()
        Specified by:
        getMessageBus in interface Scene
        Returns:
        scene message bus
      • init

        public void init​(@NotNull
                         @NotNull Game game)
        Description copied from interface: Scene
        Performs scene initialization
        Specified by:
        init in interface Scene
        Parameters:
        game - the game this scene belongs to.
      • addListener

        @NotNull
        public @NotNull Disposable addListener​(@NotNull
                                               @NotNull SceneListener listener)
        Description copied from interface: Scene
        Adds listener that can respond to scene's lifecycle events.
        Specified by:
        addListener in interface Scene
        Parameters:
        listener - the listener to add.
        Returns:
        disposable object that can be used to unregister listener.
      • show

        public void show()
        Description copied from interface: Scene
        Shows the scene.
        Specified by:
        show in interface Scene
      • hide

        public void hide()
        Description copied from interface: Scene
        Hides the scene.
        Specified by:
        hide in interface Scene
      • render

        public void render​(float deltaTime)
        Description copied from interface: Scene
        Renders the scene.
        Specified by:
        render in interface Scene
        Parameters:
        deltaTime - time passed from the previous render.
      • resize

        public void resize​(int width,
                           int height)
        Description copied from interface: Scene
        Resizes the scene to new dimensions.
        Specified by:
        resize in interface Scene
        Parameters:
        width - new scene width
        height - new scene height
      • addActor

        public void addActor​(@NotNull
                             @NotNull Actor actor)
        Description copied from interface: Scene
        Adds actor to the scene.
        Specified by:
        addActor in interface Scene
        Parameters:
        actor - actor to add.
      • removeActor

        public void removeActor​(@NotNull
                                @NotNull Actor actor)
        Description copied from interface: Scene
        Removes actor from the scene.
        Specified by:
        removeActor in interface Scene
        Parameters:
        actor - actor to remove.
      • setActorRenderOrder

        public void setActorRenderOrder​(@NotNull
                                        @NotNull java.util.List<java.lang.Class<?>> actorClasses)
        Description copied from interface: Scene
        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.
        Specified by:
        setActorRenderOrder in interface Scene
      • scheduleAction

        @NotNull
        public @NotNull Disposable scheduleAction​(@NotNull
                                                  @NotNull Action<?> action)
        Description copied from interface: Scene
        Schedules action to be executed on the scene (with no specific actor).
        Specified by:
        scheduleAction in interface Scene
        Parameters:
        action - action to schedule.
        Returns:
        Disposable object that can cancel the action.
      • scheduleAction

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

        public void cancelActions​(@NotNull
                                  @NotNull Actor actor)
        Description copied from interface: Scene
        Cancels all actions associated with given actor.
        Specified by:
        cancelActions in interface Scene
      • centerOn

        public void centerOn​(int x,
                             int y)
        Description copied from interface: Scene
        Centers the scene's camera on the [x, y] point.
        Specified by:
        centerOn in interface Scene
      • follow

        public void follow​(@NotNull
                           @NotNull Actor actor)
        Description copied from interface: Scene
        Starts to following actor with the camera.
        Specified by:
        follow in interface Scene
        Parameters:
        actor - actor that should remain centered in the camera's view.
      • stopFollowing

        public void stopFollowing()
        Description copied from interface: Scene
        Stops the camera from following actors.
        Specified by:
        stopFollowing in interface Scene
      • iterator

        @NotNull
        public @NotNull java.util.Iterator<Actor> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<Actor>
      • dispose

        public void dispose()
        Description copied from interface: Scene
        Disposes the scene resources.
        Specified by:
        dispose in interface Scene