- All Implemented Interfaces:
Rotatable
,Effectable
,Anchorable
,Bounded
,DragRepositoryAccessor
,EventInitiator
,GameNode
,Placeable
,Removable
,SceneChild
,Initializable
,com.github.hanyaeger.core.scenes.DimensionsProvider
,TimerListProvider
- Direct Known Subclasses:
CompositeEntity
,ShapeEntity
,SpriteEntity
YaegerEntity
is the base class for all things that can be drawn on a
YaegerScene
.-
Field Summary
Fields inherited from class com.github.hanyaeger.core.YaegerGameObject
colorAdjust
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
YaegerEntity
(Coordinate2D initialLocation) Create a newYaegerEntity
on the givenCoordinate2D
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addToEntityCollection
(EntityCollection collection) void
addToParent
(EntityProcessor processor) TheNode
encapsulated by thisYaegerEntity
should be added to a parentNode
to be displayed on the screen and become part of theYaegerScene
.double
angleTo
(Coordinate2D otherLocation) Computes the angle (in degrees) between the unit vector that originates at thegetAnchorLocation()
of thisYaegerEntity
and the vector with its origin at that samegetAnchorLocation()
that points towards the specifiedCoordinate2D
.double
angleTo
(YaegerEntity entity) Computes the angle (in degrees) between the unit vector that originates at thegetAnchorLocation()
point of thisYaegerEntity
and the vector with its origin at that samegetAnchorLocation()
that points towards thegetAnchorLocation()
of the specifiedYaegerEntity
.void
applyEntityProcessor
(EntityProcessor processor) Apply anEntityProcessor
to thisYaegerEntity
.void
void
attachEventListener
(javafx.event.EventType eventType, javafx.event.EventHandler eventHandler) Attach anEventHandler
for the givenEventType
.double
distanceTo
(Coordinate2D location) double
distanceTo
(YaegerEntity entity) Calculates the distance to a givenYaegerEntity
.Return theCoordinate2D
where theAnchorPoint
of thisYaegerEntity
is placed, within theYaegerScene
.Return theAnchorPoint
of thisPlaceable
.javafx.scene.Cursor
Return theCursor
that is currently being used.Return theDragNDropRepository
that was set on thisDragRepositoryAccessor
.Return an instance ofInitializationBuffer
to be used whenever aNode
is unavailable to apply the rotation.protected Coordinate2D
Calculate the absolute location of thisYaegerEntity
in the scene.double
Return the opacity of thisYaegerEntity
, meaning how opaque (that is, solid) theYaegerEntity
appears.javafx.scene.layout.Pane
Return the root pane to which thisYaegerEntity
is added.double
Return the height of theYaegerScene
that thisEntity
is part of.double
Return the width of theYaegerScene
that thisEntity
is part of.double
Return the viewOrder of thisYaegerEntity
.void
init
(com.google.inject.Injector injector) boolean
Return the visibility of thisYaegerEntity
.void
remove()
Perform all necessary actions to remove the entity.void
setAnchorLocation
(Coordinate2D anchorLocation) Set theCoordinate2D
where theAnchorPoint
of thisYaegerEntity
will be placed, within theYaegerScene
.void
setAnchorLocationX
(double x) Set the x-coordinate of theAnchorLocation
of thisYaegerEntity
;void
setAnchorLocationY
(double y) Set the y-coordinate of theAnchorLocation
of thisYaegerEntity
;void
setAnchorPoint
(AnchorPoint anchorPoint) Set theAnchorPoint
of thisPlaceable
.void
setCursor
(javafx.scene.Cursor cursor) Set the cursor to be shown.void
setDragNDropRepository
(DragNDropRepository dragNDropRepository) Set theDragNDropRepository
to be used.void
setOpacity
(double opacity) Specifies how opaque (that is, solid) theYaegerEntity
appears.void
setRootPane
(javafx.scene.layout.Pane rootPane) Set the root pane to which thisYaegerEntity
is added.void
setViewOrder
(double viewOrder) Set the viewOrder of thisYaegerEntity
.void
setVisible
(boolean visible) Change the visibility of thisYaegerEntity
.void
Transfer the x and y-coordinate of thisYaegerEntity
to its JavaFXNode
and apply the requested transformations.Methods inherited from class com.github.hanyaeger.core.YaegerGameObject
getBrightness, getContrast, getHue, getSaturation, setBrightness, setContrast, setHue, setSaturation
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.github.hanyaeger.core.entities.Bounded
getBoundingBox, getHeight, getWidth
Methods inherited from interface com.github.hanyaeger.core.Initializable
beforeInitialize
Methods inherited from interface com.github.hanyaeger.core.entities.Removable
notifyRemove
Methods inherited from interface com.github.hanyaeger.api.entities.Rotatable
getRotation, setRotate
-
Constructor Details
-
YaegerEntity
Create a newYaegerEntity
on the givenCoordinate2D
.- Parameters:
initialLocation
- the initialCoordinate2D
of thisYaegerEntity
-
-
Method Details
-
setCursor
public void setCursor(javafx.scene.Cursor cursor) Set the cursor to be shown. This cursor will be applied to the wholeYaegerScene
.- Parameters:
cursor
- theCursor
to be shown
-
getCursor
public javafx.scene.Cursor getCursor()Return theCursor
that is currently being used. If thisYaegerEntity
is not yet part of aYaegerScene
, this method will returnnull
.- Returns:
- the
Cursor
-
setVisible
public void setVisible(boolean visible) Change the visibility of thisYaegerEntity
. The value can be eithertrue
orfalse
. Use the methodsetOpacity(double)
to set the transparency of theYaegerEntity
.- Parameters:
visible
- aboolean
representing the visibility if theYaegerEntity
-
isVisible
public boolean isVisible()Return the visibility of thisYaegerEntity
.- Returns:
- the visibility of this
YaegerEntity
as aboolean
-
setOpacity
public void setOpacity(double opacity) Specifies how opaque (that is, solid) theYaegerEntity
appears. An Entity with 0% opacity is fully translucent. That is, while it is still visible and rendered, you generally won't be able to see it.Opacity is specified as a value between 0 and 1. Values less than 0 are treated as 0, values greater than 1 are treated as 1.
- Parameters:
opacity
- adouble
between 0 and 1
-
getOpacity
public double getOpacity()Return the opacity of thisYaegerEntity
, meaning how opaque (that is, solid) theYaegerEntity
appears. AnYaegerEntity
with 0% opacity is fully translucent. That is, while it is still visible and rendered, you generally won't be able to see it.Opacity is specified as a value between 0 and 1. Values less than 0 are treated as 0, values greater than 1 are treated as 1.
- Returns:
- the opacity of this
YaegerEntity
-
distanceTo
Calculates the distance to a givenYaegerEntity
. This distance is based on theAnchorPoint
of the Entities and not on the shortest distance between them.- Parameters:
entity
- theYaegerEntity
to which the distance should be calculated.- Returns:
- The distance as a
double
-
distanceTo
- Parameters:
location
- theCoordinate2D
to which the distance should be calculated- Returns:
- the distance as a
double
-
angleTo
Computes the angle (in degrees) between the unit vector that originates at thegetAnchorLocation()
point of thisYaegerEntity
and the vector with its origin at that samegetAnchorLocation()
that points towards thegetAnchorLocation()
of the specifiedYaegerEntity
. Note that the unit vector points downwards, so:- If
otherLocation
is directly below the reference point of thisYaegerEntity
, the angle will be 0 degrees. - If
otherLocation
is directly above the reference point of thisYaegerEntity
, the angle will be 180 degrees. - If
otherLocation
is directly to the right of the reference point of thisYaegerEntity
, the angle will be 90 degrees. - If
otherLocation
is directly to the left of the reference point of thisYaegerEntity
, the angle will be 270 degrees.
- Parameters:
entity
- theYaegerEntity
of the other vector- Returns:
- the angle between the two vectors measured in degrees,
NaN
if any of the two vectors is a zero vector - Throws:
NullPointerException
- if the specifiedlocation
isnull
- If
-
angleTo
Computes the angle (in degrees) between the unit vector that originates at thegetAnchorLocation()
of thisYaegerEntity
and the vector with its origin at that samegetAnchorLocation()
that points towards the specifiedCoordinate2D
. Note that the unit vector points downwards, so:- If
otherLocation
is directly below the reference point of thisYaegerEntity
, the angle will be 0 degrees. - If
otherLocation
is directly above the reference point of thisYaegerEntity
, the angle will be 180 degrees. - If
otherLocation
is directly to the right of the reference point of thisYaegerEntity
, the angle will be 90 degrees. - If
otherLocation
is directly to the left of the reference point of thisYaegerEntity
, the angle will be 270 degrees.
- Parameters:
otherLocation
- theCoordinate2D
of the other vector- Returns:
- the angle between the two vectors measured in degrees,
NaN
if any of the two vectors is a zero vector - Throws:
NullPointerException
- if the specifiedotherLocation
is null
- If
-
addToEntityCollection
Add thisYaegerEntity
to theEntityCollection
, which will make it part of theYaegerGame
. Since anEntityCollection
contains different lists of Entities, aYaegerEntity
itself is responsible for knowing to which list it should be added.Note: This method is part of the internal API, and should not be used when implementing a Yaeger game.
- Parameters:
collection
- theEntityCollection
to which thisYaegerEntity
should add itself
-
applyTranslationsForAnchorPoint
public void applyTranslationsForAnchorPoint()AYaegerEntity
's location is defined by itsanchorLocation
and itsanchorPoint
. For most implementation ofYaegerEntity
, the defaultanchorPoint
isTOP_LEFT
. Using a differentanchorpoint
will mean a translation will be applied. ItsanchorLocation
will remain te same.Note: This method is part of the internal API, and should not be used when implementing a Yaeger game.
-
init
public void init(com.google.inject.Injector injector) - Specified by:
init
in interfaceInitializable
- Parameters:
injector
- theInjector
used for Dependency InjectionNote: This method is part of the internal API, and should not be used when implementing a Yaeger game.
-
setAnchorPoint
Description copied from interface:Anchorable
Set theAnchorPoint
of thisPlaceable
. TheAnchorPoint
can be used for aligning theYaegerEntity
, and will be used to set the given x, y-coordinate. By default, aPlaceable
will use the top-left as its anchor-point.- Specified by:
setAnchorPoint
in interfaceAnchorable
- Parameters:
anchorPoint
- theAnchorPoint
of thisYaegerEntity
-
getAnchorPoint
Description copied from interface:Anchorable
Return theAnchorPoint
of thisPlaceable
.- Specified by:
getAnchorPoint
in interfaceAnchorable
- Returns:
- the
AnchorPoint
of thisPlaceable
-
setAnchorLocation
Description copied from interface:Placeable
Set theCoordinate2D
where theAnchorPoint
of thisYaegerEntity
will be placed, within theYaegerScene
.- Specified by:
setAnchorLocation
in interfacePlaceable
- Parameters:
anchorLocation
- theCoordinate2D
that should be used
-
getAnchorLocation
Description copied from interface:Placeable
Return theCoordinate2D
where theAnchorPoint
of thisYaegerEntity
is placed, within theYaegerScene
.- Specified by:
getAnchorLocation
in interfacePlaceable
- Returns:
- the
Coordinate2D
that is currently being used
-
setAnchorLocationX
public void setAnchorLocationX(double x) Description copied from interface:Placeable
Set the x-coordinate of theAnchorLocation
of thisYaegerEntity
;- Specified by:
setAnchorLocationX
in interfacePlaceable
- Parameters:
x
- the x-coordinate as adouble
-
setAnchorLocationY
public void setAnchorLocationY(double y) Description copied from interface:Placeable
Set the y-coordinate of theAnchorLocation
of thisYaegerEntity
;- Specified by:
setAnchorLocationY
in interfacePlaceable
- Parameters:
y
- the y-coordinate as adouble
-
remove
public void remove()Description copied from interface:Removable
Perform all necessary actions to remove the entity. -
getTimers
Description copied from interface:TimerListProvider
- Specified by:
getTimers
in interfaceTimerListProvider
- Returns:
- the
List
ofTimer
instances
-
transferCoordinatesToNode
public void transferCoordinatesToNode()Description copied from interface:Placeable
Transfer the x and y-coordinate of thisYaegerEntity
to its JavaFXNode
and apply the requested transformations.Note: This method is part of the internal API, and should not be used when implementing a Yaeger game.
- Specified by:
transferCoordinatesToNode
in interfacePlaceable
-
attachEventListener
public void attachEventListener(javafx.event.EventType eventType, javafx.event.EventHandler eventHandler) Description copied from interface:EventInitiator
Attach anEventHandler
for the givenEventType
.Note: This method is part of the internal API, and should not be used when implementing a Yaeger game.
- Specified by:
attachEventListener
in interfaceEventInitiator
- Parameters:
eventType
- theEventType
that should trigger the givenEventHandler
eventHandler
- theEventHandler
that should be called whenever an event of typeEventType
occurs
-
applyEntityProcessor
Apply anEntityProcessor
to thisYaegerEntity
. AnEntityProcessor
is most likely a lambda expression passed by a parent object.Note: This method is part of the internal API, and should not be used when implementing a Yaeger game.
- Parameters:
processor
- an instance ofEntityProcessor
, most likely a lambda expression that should be called for processing thisYaegerEntity
-
addToParent
TheNode
encapsulated by thisYaegerEntity
should be added to a parentNode
to be displayed on the screen and become part of theYaegerScene
.Note: This method is part of the internal API, and should not be used when implementing a Yaeger game.
- Parameters:
processor
- an instance ofEntityProcessor
, most likely a lambda expression that can be used for adding this node as a child to a parent node
-
getInitializationBuffer
Description copied from interface:Rotatable
Return an instance ofInitializationBuffer
to be used whenever aNode
is unavailable to apply the rotation.- Specified by:
getInitializationBuffer
in interfaceRotatable
- Returns:
- An instance of
InitializationBuffer
.
-
getDragNDropRepository
Description copied from interface:DragRepositoryAccessor
Return theDragNDropRepository
that was set on thisDragRepositoryAccessor
.Note: This method is part of the internal API, and should not be used when implementing a Yaeger game.
- Specified by:
getDragNDropRepository
in interfaceDragRepositoryAccessor
- Returns:
- the instance of
DragNDropRepository
-
setViewOrder
public void setViewOrder(double viewOrder) Set the viewOrder of thisYaegerEntity
. The viewOrder defines the rendering order of thisYaegerEntity
within theYaegerScene
. The lower the viewOrder, the closer theYaegerEntity
is to the front of theYaegerScene
.By default, a
YaegerEntity
will receive the viewOrder ofViewOrders.VIEW_ORDER_ENTITY_DEFAULT
. AYaegerEntity
that is part of anTileMap
will default to the value 100 to ensure it is placed behind other Entities.- Parameters:
viewOrder
- the value of viewOrder as adouble
-
getViewOrder
public double getViewOrder()Return the viewOrder of thisYaegerEntity
. The viewOrder defines the rendering order of thisYaegerEntity
within theYaegerScene
. The lower the viewOrder, the closer theYaegerEntity
is to the front of theYaegerScene
.By default, a
YaegerEntity
will receive the viewOrder ofViewOrders.VIEW_ORDER_ENTITY_DEFAULT
. AYaegerEntity
that is part of anTileMap
will default to the value 100 to ensure it is placed behind other Entities.- Returns:
- the value of viewOrder as a
double
-
getLocationInScene
Calculate the absolute location of thisYaegerEntity
in the scene. BecauseCompositeEntity
uses a relative coordinate system, this method is needed to make calculations for entities that are part of aCompositeEntity
.- Returns:
- a
Coordinate2D
with the absolute coordinates of theYaegerEntity
.
-
getRootPane
public javafx.scene.layout.Pane getRootPane()Return the root pane to which thisYaegerEntity
is added.Note: This method is part of the internal API, and should not be used when implementing a Yaeger game.
- Returns:
- the root pane, which is an instance of
Pane
-
setRootPane
public void setRootPane(javafx.scene.layout.Pane rootPane) Set the root pane to which thisYaegerEntity
is added.Note: This method is part of the internal API, and should not be used when implementing a Yaeger game.
- Parameters:
rootPane
- the root pane, which is an instance ofPane
-
setDragNDropRepository
Set theDragNDropRepository
to be used.- Specified by:
setDragNDropRepository
in interfaceDragRepositoryAccessor
- Parameters:
dragNDropRepository
- theDragNDropRepository
to be used
-
getSceneWidth
public double getSceneWidth()Description copied from interface:SceneChild
Return the width of theYaegerScene
that thisEntity
is part of. For both aStaticScene
andDynamicScene
, the full width is always visible. In case of aScrollableDynamicScene
, this is not the case, since it can be larger that the viewable area.- Specified by:
getSceneWidth
in interfaceSceneChild
- Returns:
- the width of this
YaegerScene
as adouble
-
getSceneHeight
public double getSceneHeight()Description copied from interface:SceneChild
Return the height of theYaegerScene
that thisEntity
is part of. For both aStaticScene
andDynamicScene
, the full height is always visible. In case of aScrollableDynamicScene
, this is not the case, since it can be larger that the viewable area.- Specified by:
getSceneHeight
in interfaceSceneChild
- Returns:
- the height of this
YaegerScene
as adouble
-