- 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
ConstructorsModifierConstructorDescriptionprotectedYaegerEntity(Coordinate2D initialLocation) Create a newYaegerEntityon the givenCoordinate2D. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToEntityCollection(EntityCollection collection) voidaddToParent(EntityProcessor processor) TheNodeencapsulated by thisYaegerEntityshould be added to a parentNodeto be displayed on the screen and become part of theYaegerScene.doubleangleTo(Coordinate2D otherLocation) Computes the angle (in degrees) between the unit vector that originates at thegetAnchorLocation()of thisYaegerEntityand the vector with its origin at that samegetAnchorLocation()that points towards the specifiedCoordinate2D.doubleangleTo(YaegerEntity entity) Computes the angle (in degrees) between the unit vector that originates at thegetAnchorLocation()point of thisYaegerEntityand the vector with its origin at that samegetAnchorLocation()that points towards thegetAnchorLocation()of the specifiedYaegerEntity.voidapplyEntityProcessor(EntityProcessor processor) Apply anEntityProcessorto thisYaegerEntity.voidvoidattachEventListener(javafx.event.EventType eventType, javafx.event.EventHandler eventHandler) Attach anEventHandlerfor the givenEventType.doubledistanceTo(Coordinate2D location) doubledistanceTo(YaegerEntity entity) Calculates the distance to a givenYaegerEntity.Return theCoordinate2Dwhere theAnchorPointof thisYaegerEntityis placed, within theYaegerScene.Return theAnchorPointof thisPlaceable.javafx.scene.CursorReturn theCursorthat is currently being used.Return theDragNDropRepositorythat was set on thisDragRepositoryAccessor.Return an instance ofInitializationBufferto be used whenever aNodeis unavailable to apply the rotation.protected Coordinate2DCalculate the absolute location of thisYaegerEntityin the scene.doubleReturn the opacity of thisYaegerEntity, meaning how opaque (that is, solid) theYaegerEntityappears.javafx.scene.layout.PaneReturn the root pane to which thisYaegerEntityis added.doubleReturn the height of theYaegerScenethat thisEntityis part of.doubleReturn the width of theYaegerScenethat thisEntityis part of.doubleReturn the viewOrder of thisYaegerEntity.voidinit(com.google.inject.Injector injector) booleanReturn the visibility of thisYaegerEntity.voidremove()Perform all necessary actions to remove the entity.voidsetAnchorLocation(Coordinate2D anchorLocation) Set theCoordinate2Dwhere theAnchorPointof thisYaegerEntitywill be placed, within theYaegerScene.voidsetAnchorLocationX(double x) Set the x-coordinate of theAnchorLocationof thisYaegerEntity;voidsetAnchorLocationY(double y) Set the y-coordinate of theAnchorLocationof thisYaegerEntity;voidsetAnchorPoint(AnchorPoint anchorPoint) Set theAnchorPointof thisPlaceable.voidsetCursor(javafx.scene.Cursor cursor) Set the cursor to be shown.voidsetDragNDropRepository(DragNDropRepository dragNDropRepository) Set theDragNDropRepositoryto be used.voidsetOpacity(double opacity) Specifies how opaque (that is, solid) theYaegerEntityappears.voidsetRootPane(javafx.scene.layout.Pane rootPane) Set the root pane to which thisYaegerEntityis added.voidsetViewOrder(double viewOrder) Set the viewOrder of thisYaegerEntity.voidsetVisible(boolean visible) Change the visibility of thisYaegerEntity.voidTransfer the x and y-coordinate of thisYaegerEntityto its JavaFXNodeand apply the requested transformations.Methods inherited from class com.github.hanyaeger.core.YaegerGameObject
getBrightness, getContrast, getHue, getSaturation, setBrightness, setContrast, setHue, setSaturationMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.github.hanyaeger.core.entities.Bounded
getBoundingBox, getHeight, getWidthMethods inherited from interface com.github.hanyaeger.core.Initializable
beforeInitializeMethods inherited from interface com.github.hanyaeger.core.entities.Removable
notifyRemoveMethods inherited from interface com.github.hanyaeger.api.entities.Rotatable
getRotation, setRotate
-
Constructor Details
-
YaegerEntity
Create a newYaegerEntityon the givenCoordinate2D.- Parameters:
initialLocation- the initialCoordinate2Dof 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- theCursorto be shown
-
getCursor
public javafx.scene.Cursor getCursor()Return theCursorthat is currently being used. If thisYaegerEntityis 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 eithertrueorfalse. Use the methodsetOpacity(double)to set the transparency of theYaegerEntity.- Parameters:
visible- abooleanrepresenting the visibility if theYaegerEntity
-
isVisible
public boolean isVisible()Return the visibility of thisYaegerEntity.- Returns:
- the visibility of this
YaegerEntityas aboolean
-
setOpacity
public void setOpacity(double opacity) Specifies how opaque (that is, solid) theYaegerEntityappears. 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- adoublebetween 0 and 1
-
getOpacity
public double getOpacity()Return the opacity of thisYaegerEntity, meaning how opaque (that is, solid) theYaegerEntityappears. AnYaegerEntitywith 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 theAnchorPointof the Entities and not on the shortest distance between them.- Parameters:
entity- theYaegerEntityto which the distance should be calculated.- Returns:
- The distance as a
double
-
distanceTo
- Parameters:
location- theCoordinate2Dto 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 thisYaegerEntityand the vector with its origin at that samegetAnchorLocation()that points towards thegetAnchorLocation()of the specifiedYaegerEntity. Note that the unit vector points downwards, so:- If
otherLocationis directly below the reference point of thisYaegerEntity, the angle will be 0 degrees. - If
otherLocationis directly above the reference point of thisYaegerEntity, the angle will be 180 degrees. - If
otherLocationis directly to the right of the reference point of thisYaegerEntity, the angle will be 90 degrees. - If
otherLocationis directly to the left of the reference point of thisYaegerEntity, the angle will be 270 degrees.
- Parameters:
entity- theYaegerEntityof the other vector- Returns:
- the angle between the two vectors measured in degrees,
NaNif any of the two vectors is a zero vector - Throws:
NullPointerException- if the specifiedlocationisnull
- If
-
angleTo
Computes the angle (in degrees) between the unit vector that originates at thegetAnchorLocation()of thisYaegerEntityand the vector with its origin at that samegetAnchorLocation()that points towards the specifiedCoordinate2D. Note that the unit vector points downwards, so:- If
otherLocationis directly below the reference point of thisYaegerEntity, the angle will be 0 degrees. - If
otherLocationis directly above the reference point of thisYaegerEntity, the angle will be 180 degrees. - If
otherLocationis directly to the right of the reference point of thisYaegerEntity, the angle will be 90 degrees. - If
otherLocationis directly to the left of the reference point of thisYaegerEntity, the angle will be 270 degrees.
- Parameters:
otherLocation- theCoordinate2Dof the other vector- Returns:
- the angle between the two vectors measured in degrees,
NaNif any of the two vectors is a zero vector - Throws:
NullPointerException- if the specifiedotherLocationis null
- If
-
addToEntityCollection
Add thisYaegerEntityto theEntityCollection, which will make it part of theYaegerGame. Since anEntityCollectioncontains different lists of Entities, aYaegerEntityitself 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- theEntityCollectionto which thisYaegerEntityshould add itself
-
applyTranslationsForAnchorPoint
public void applyTranslationsForAnchorPoint()AYaegerEntity's location is defined by itsanchorLocationand itsanchorPoint. For most implementation ofYaegerEntity, the defaultanchorPointisTOP_LEFT. Using a differentanchorpointwill mean a translation will be applied. ItsanchorLocationwill 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:
initin interfaceInitializable- Parameters:
injector- theInjectorused 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:AnchorableSet theAnchorPointof thisPlaceable. TheAnchorPointcan be used for aligning theYaegerEntity, and will be used to set the given x, y-coordinate. By default, aPlaceablewill use the top-left as its anchor-point.- Specified by:
setAnchorPointin interfaceAnchorable- Parameters:
anchorPoint- theAnchorPointof thisYaegerEntity
-
getAnchorPoint
Description copied from interface:AnchorableReturn theAnchorPointof thisPlaceable.- Specified by:
getAnchorPointin interfaceAnchorable- Returns:
- the
AnchorPointof thisPlaceable
-
setAnchorLocation
Description copied from interface:PlaceableSet theCoordinate2Dwhere theAnchorPointof thisYaegerEntitywill be placed, within theYaegerScene.- Specified by:
setAnchorLocationin interfacePlaceable- Parameters:
anchorLocation- theCoordinate2Dthat should be used
-
getAnchorLocation
Description copied from interface:PlaceableReturn theCoordinate2Dwhere theAnchorPointof thisYaegerEntityis placed, within theYaegerScene.- Specified by:
getAnchorLocationin interfacePlaceable- Returns:
- the
Coordinate2Dthat is currently being used
-
setAnchorLocationX
public void setAnchorLocationX(double x) Description copied from interface:PlaceableSet the x-coordinate of theAnchorLocationof thisYaegerEntity;- Specified by:
setAnchorLocationXin interfacePlaceable- Parameters:
x- the x-coordinate as adouble
-
setAnchorLocationY
public void setAnchorLocationY(double y) Description copied from interface:PlaceableSet the y-coordinate of theAnchorLocationof thisYaegerEntity;- Specified by:
setAnchorLocationYin interfacePlaceable- Parameters:
y- the y-coordinate as adouble
-
remove
public void remove()Description copied from interface:RemovablePerform all necessary actions to remove the entity. -
getTimers
Description copied from interface:TimerListProvider- Specified by:
getTimersin interfaceTimerListProvider- Returns:
- the
ListofTimerinstances
-
transferCoordinatesToNode
public void transferCoordinatesToNode()Description copied from interface:PlaceableTransfer the x and y-coordinate of thisYaegerEntityto its JavaFXNodeand 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:
transferCoordinatesToNodein interfacePlaceable
-
attachEventListener
public void attachEventListener(javafx.event.EventType eventType, javafx.event.EventHandler eventHandler) Description copied from interface:EventInitiatorAttach anEventHandlerfor the givenEventType.Note: This method is part of the internal API, and should not be used when implementing a Yaeger game.
- Specified by:
attachEventListenerin interfaceEventInitiator- Parameters:
eventType- theEventTypethat should trigger the givenEventHandlereventHandler- theEventHandlerthat should be called whenever an event of typeEventTypeoccurs
-
applyEntityProcessor
Apply anEntityProcessorto thisYaegerEntity. AnEntityProcessoris 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
TheNodeencapsulated by thisYaegerEntityshould be added to a parentNodeto 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:RotatableReturn an instance ofInitializationBufferto be used whenever aNodeis unavailable to apply the rotation.- Specified by:
getInitializationBufferin interfaceRotatable- Returns:
- An instance of
InitializationBuffer.
-
getDragNDropRepository
Description copied from interface:DragRepositoryAccessorReturn theDragNDropRepositorythat 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:
getDragNDropRepositoryin interfaceDragRepositoryAccessor- Returns:
- the instance of
DragNDropRepository
-
setViewOrder
public void setViewOrder(double viewOrder) Set the viewOrder of thisYaegerEntity. The viewOrder defines the rendering order of thisYaegerEntitywithin theYaegerScene. The lower the viewOrder, the closer theYaegerEntityis to the front of theYaegerScene.By default, a
YaegerEntitywill receive the viewOrder ofViewOrders.VIEW_ORDER_ENTITY_DEFAULT. AYaegerEntitythat is part of anTileMapwill 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 thisYaegerEntitywithin theYaegerScene. The lower the viewOrder, the closer theYaegerEntityis to the front of theYaegerScene.By default, a
YaegerEntitywill receive the viewOrder ofViewOrders.VIEW_ORDER_ENTITY_DEFAULT. AYaegerEntitythat is part of anTileMapwill 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 thisYaegerEntityin the scene. BecauseCompositeEntityuses a relative coordinate system, this method is needed to make calculations for entities that are part of aCompositeEntity.- Returns:
- a
Coordinate2Dwith the absolute coordinates of theYaegerEntity.
-
getRootPane
public javafx.scene.layout.Pane getRootPane()Return the root pane to which thisYaegerEntityis 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 thisYaegerEntityis 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 theDragNDropRepositoryto be used.- Specified by:
setDragNDropRepositoryin interfaceDragRepositoryAccessor- Parameters:
dragNDropRepository- theDragNDropRepositoryto be used
-
getSceneWidth
public double getSceneWidth()Description copied from interface:SceneChildReturn the width of theYaegerScenethat thisEntityis part of. For both aStaticSceneandDynamicScene, 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:
getSceneWidthin interfaceSceneChild- Returns:
- the width of this
YaegerSceneas adouble
-
getSceneHeight
public double getSceneHeight()Description copied from interface:SceneChildReturn the height of theYaegerScenethat thisEntityis part of. For both aStaticSceneandDynamicScene, 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:
getSceneHeightin interfaceSceneChild- Returns:
- the height of this
YaegerSceneas adouble
-