Package sk.tuke.kpi.gamelib
Class World
- java.lang.Object
-
- sk.tuke.kpi.gamelib.World
-
-
Field Summary
Fields Modifier and Type Field Description static Topic<Actor>
ACTOR_ADDED_TOPIC
Topic for actors added to the scene.static Topic<Actor>
ACTOR_REMOVED_TOPIC
Topic for actors removed from the scene.
-
Constructor Summary
Constructors Constructor Description World()
World(@Nullable java.lang.String name)
World(@Nullable java.lang.String name, @Nullable java.lang.String mapResource)
World(@Nullable java.lang.String name, @Nullable java.lang.String mapResource, @Nullable ActorFactory actorFactory)
World(@Nullable java.lang.String mapResource, @Nullable ActorFactory actorFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addActor(@NotNull Actor actor)
Adds actor to the scene.@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()
@NotNull Game
getGame()
@NotNull Input
getInput()
Gets input processor with listeners specific for the scene.@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.@NotNull java.util.Iterator<Actor>
iterator()
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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface sk.tuke.kpi.gamelib.Scene
addActor, getFirstActorByName, getFirstActorByType, getLastActorByName, getLastActorByType
-
-
-
-
Field Detail
-
ACTOR_ADDED_TOPIC
public static final Topic<Actor> ACTOR_ADDED_TOPIC
Topic for actors added to the scene. Published to by theaddActor(Actor)
method.
-
ACTOR_REMOVED_TOPIC
public static final Topic<Actor> ACTOR_REMOVED_TOPIC
Topic for actors removed from the scene. Published to by theremoveActor(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()
-
getActorFactory
@Nullable public @Nullable ActorFactory getActorFactory()
- Specified by:
getActorFactory
in interfaceScene
- 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 interfaceScene
- Returns:
- true when the scene was initialized already, false otherwise
-
getGame
@NotNull public @NotNull Game getGame()
-
getOverlay
@NotNull public @NotNull Overlay getOverlay()
- Specified by:
getOverlay
in interfaceScene
- Returns:
- scene overlay
-
getMap
@NotNull public @NotNull SceneMap getMap()
-
getCamera
@NotNull public @NotNull com.badlogic.gdx.graphics.OrthographicCamera getCamera()
-
getInput
@NotNull public @NotNull Input getInput()
Description copied from interface:Scene
Gets input processor with listeners specific for the scene.- Specified by:
getInput
in interfaceScene
- Returns:
- scene input processor
- See Also:
Game.getInput()
-
getActors
@NotNull public @NotNull java.util.List<Actor> getActors()
-
getActions
@NotNull public @NotNull java.util.List<Action<?>> getActions()
- Specified by:
getActions
in interfaceScene
- Returns:
- list of all actions currently scheduled on some actor.
-
getListeners
@NotNull public @NotNull java.util.List<SceneListener> getListeners()
- Specified by:
getListeners
in interfaceScene
- Returns:
- scene lifecycle listeners
-
getMessageBus
@NotNull public @NotNull MessageBus getMessageBus()
- Specified by:
getMessageBus
in interfaceScene
- Returns:
- scene message bus
-
init
public void init(@NotNull @NotNull Game game)
Description copied from interface:Scene
Performs scene initialization
-
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 interfaceScene
- 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.
-
hide
public void hide()
Description copied from interface:Scene
Hides the scene.
-
render
public void render(float deltaTime)
Description copied from interface:Scene
Renders the scene.
-
resize
public void resize(int width, int height)
Description copied from interface:Scene
Resizes the scene to new dimensions.
-
addActor
public void addActor(@NotNull @NotNull Actor actor)
Description copied from interface:Scene
Adds actor to the scene.
-
removeActor
public void removeActor(@NotNull @NotNull Actor actor)
Description copied from interface:Scene
Removes actor from the scene.- Specified by:
removeActor
in interfaceScene
- 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:- 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.
- Specified by:
setActorRenderOrder
in interfaceScene
-
scheduleAction
@NotNull public @NotNull Disposable scheduleAction(@NotNull @NotNull Action<?> action)
Description copied from interface:Scene
Schedules action to beexecuted
on the scene (with no specific actor).- Specified by:
scheduleAction
in interfaceScene
- 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 beexecuted
on actor.- Specified by:
scheduleAction
in interfaceScene
- 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 interfaceScene
-
centerOn
public void centerOn(int x, int y)
Description copied from interface:Scene
Centers the scene'scamera
on the [x
,y
] point.
-
follow
public void follow(@NotNull @NotNull Actor actor)
Description copied from interface:Scene
Starts to following actor with thecamera
.
-
stopFollowing
public void stopFollowing()
Description copied from interface:Scene
Stops thecamera
from following actors.- Specified by:
stopFollowing
in interfaceScene
-
iterator
@NotNull public @NotNull java.util.Iterator<Actor> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<Actor>
-
-