Package sk.tuke.kpi.gamelib
Interface Scene
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addActor(@NotNull Actor actor)
Adds actor to the scene.default void
addActor(@NotNull Actor actor, int posX, int posY)
Adds actor to the scene at [posX, posY] coordinates.@NotNull Disposable
addListener(@NotNull SceneListener listener)
Adds listener that can respond to scene's lifecycle events.void
cancelActions(@NotNull Actor actor)
Cancels all actions associated with given actor.void
centerOn(int x, int y)
Centers the scene'scamera
on the [x
,y
] point.void
dispose()
Disposes the scene resources.void
follow(@NotNull Actor actor)
Starts to following actor with thecamera
.@NotNull java.util.List<Action<?>>
getActions()
@Nullable ActorFactory
getActorFactory()
@NotNull java.util.List<Actor>
getActors()
@NotNull com.badlogic.gdx.graphics.OrthographicCamera
getCamera()
default @Nullable Actor
getFirstActorByName(@NotNull java.lang.String name)
default <A extends Actor>
AgetFirstActorByType(@NotNull java.lang.Class<? extends A> cls)
@NotNull Game
getGame()
@NotNull Input
getInput()
Gets input processor with listeners specific for the scene.default @Nullable Actor
getLastActorByName(@NotNull java.lang.String name)
default <A extends Actor>
AgetLastActorByType(@NotNull java.lang.Class<? extends A> cls)
@NotNull java.util.List<SceneListener>
getListeners()
@NotNull SceneMap
getMap()
@NotNull MessageBus
getMessageBus()
@NotNull java.lang.String
getName()
@NotNull Overlay
getOverlay()
void
hide()
Hides the scene.void
init(@NotNull Game game)
Performs scene initializationboolean
isInitialized()
Gets initialization state of the scene.void
removeActor(@NotNull Actor actor)
Removes actor from the scene.void
render(float deltaTime)
Renders the scene.void
resize(int width, int height)
Resizes the scene to new dimensions.@NotNull Disposable
scheduleAction(@NotNull Action<?> action)
Schedules action to beexecuted
on the scene (with no specific actor).<A extends Actor>
@NotNull DisposablescheduleAction(@NotNull Action<A> action, A actor)
Schedules action to beexecuted
on actor.void
setActorRenderOrder(@NotNull java.util.List<java.lang.Class<?>> actorClasses)
Defines order of actor types used to sort actors prior to rendering.void
show()
Shows the scene.void
stopFollowing()
Stops thecamera
from following 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 addposX
- x position of actorposY
- 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:- Actor of type with higher index is rendered on top of actor of type with lower index.
- The most specific type matching an actor is always selected.
- 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 beexecuted
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 beexecuted
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'scamera
on the [x
,y
] point.
-
follow
void follow(@NotNull @NotNull Actor actor)
Starts to following actor with thecamera
.- Parameters:
actor
- actor that should remain centered in the camera's view.
-
stopFollowing
void stopFollowing()
Stops thecamera
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 widthheight
- new scene height
-
hide
void hide()
Hides the scene.
-
dispose
void dispose()
Disposes the scene resources.
-
-