Class Interactable
- java.lang.Object
-
- bytemusketeers.heslingtonhustle.scene.Item
-
- bytemusketeers.heslingtonhustle.scene.Interactable
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.RunnableactionThe action to execute afterinteract()has been finished.private floatinteractionThresholdThe square of the maximum interaction distance; that is, the maximum distance, measured by the Euclidean metric, that aCharactermay be from anInteractableto fire aninteract().
-
Constructor Summary
Constructors Modifier Constructor Description privateInteractable(com.badlogic.gdx.math.Vector2 position, com.badlogic.gdx.graphics.Texture texture, Area area, float width, float height, java.lang.Runnable action)Instantiates a newInteractableItemwith the given initial parameters(package private)Interactable(com.badlogic.gdx.math.Vector2 position, com.badlogic.gdx.graphics.Texture texture, Area area, float scale, java.lang.Runnable action)Instantiates a newInteractableItemwith the given initial parameters
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidinteract()(package private) booleanisClose(com.badlogic.gdx.math.Vector2 position)Determines if the describedVector2represents an object that is sufficiently close to theInteractable-
Methods inherited from class bytemusketeers.heslingtonhustle.scene.Item
dispose, getPosition, render
-
-
-
-
Field Detail
-
interactionThreshold
private final float interactionThreshold
The square of the maximum interaction distance; that is, the maximum distance, measured by the Euclidean metric, that aCharactermay be from anInteractableto fire aninteract().- See Also:
isClose(Vector2)
-
action
private final java.lang.Runnable action
The action to execute afterinteract()has been finished. The execution should be deferred to LibGDX to avoid potential threading-related race conditions.- See Also:
Runnable.run(),Application.postRunnable(Runnable),interact()
-
-
Constructor Detail
-
Interactable
private Interactable(com.badlogic.gdx.math.Vector2 position, com.badlogic.gdx.graphics.Texture texture, Area area, float width, float height, java.lang.Runnable action)Instantiates a newInteractableItemwith the given initial parameters- Parameters:
position- The initial position of theInteractable, specified as in-game metre componentstexture- The initialSpriteTexturearea- TheAreainto which theInteractableshould be drawnwidth- The initial width, in in-game metresheight- The initial height, in in-game metresaction- TheRunnablemethod to execute upon interaction
-
Interactable
Interactable(com.badlogic.gdx.math.Vector2 position, com.badlogic.gdx.graphics.Texture texture, Area area, float scale, java.lang.Runnable action)Instantiates a newInteractableItemwith the given initial parameters- Parameters:
position- The initial position of theInteractable, specified as in-game metre componentstexture- The initialSpriteTexturearea- TheAreainto which theInteractableshould be drawnscale- The multiplier by which the size of theTextureshould be scaled, preserving aspect ratioaction- TheRunnablemethod to execute upon interaction
-
-
Method Detail
-
interact
void interact()
- See Also:
action
-
isClose
boolean isClose(com.badlogic.gdx.math.Vector2 position)
Determines if the describedVector2represents an object that is sufficiently close to theInteractable- Parameters:
position- The position to test- Returns:
- Is the given
Vector2within the defined Euclidean distance of theInteractable? - See Also:
interactionThreshold
-
-