Class Interactable
- java.lang.Object
-
- bytemusketeers.heslingtonhustle.scene.Item
-
- bytemusketeers.heslingtonhustle.scene.Interactable
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Runnable
action
The action to execute afterinteract()
has been finished.private float
interactionThreshold
The square of the maximum interaction distance; that is, the maximum distance, measured by the Euclidean metric, that aCharacter
may be from anInteractable
to fire aninteract()
.
-
Constructor Summary
Constructors Modifier Constructor Description 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 newInteractable
Item
with 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 newInteractable
Item
with the given initial parameters
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
interact()
(package private) boolean
isClose(com.badlogic.gdx.math.Vector2 position)
Determines if the describedVector2
represents 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 aCharacter
may be from anInteractable
to 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 newInteractable
Item
with the given initial parameters- Parameters:
position
- The initial position of theInteractable
, specified as in-game metre componentstexture
- The initialSprite
Texture
area
- TheArea
into which theInteractable
should be drawnwidth
- The initial width, in in-game metresheight
- The initial height, in in-game metresaction
- TheRunnable
method 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 newInteractable
Item
with the given initial parameters- Parameters:
position
- The initial position of theInteractable
, specified as in-game metre componentstexture
- The initialSprite
Texture
area
- TheArea
into which theInteractable
should be drawnscale
- The multiplier by which the size of theTexture
should be scaled, preserving aspect ratioaction
- TheRunnable
method to execute upon interaction
-
-
Method Detail
-
interact
void interact()
- See Also:
action
-
isClose
boolean isClose(com.badlogic.gdx.math.Vector2 position)
Determines if the describedVector2
represents an object that is sufficiently close to theInteractable
- Parameters:
position
- The position to test- Returns:
- Is the given
Vector2
within the defined Euclidean distance of theInteractable
? - See Also:
interactionThreshold
-
-