FlixelGoalTween
View sourceclass
org.flixelgdx.tween.type.FlixelGoalTween
Tween type for animating any object via lambda getters and setters.
It's intended to be used the following way:
// Use the FlixelTween class to use this type.
FlixelTween.tween(myObject, new FlixelTweenSettings()
.addGoal(myObject::getFoo, 100f, myObject::setFoo)
.addGoal(myObject::getBar, 200f, myObject::setBar));
If you need to cancel a specific tween of an object, you can add a label to the tween via FlixelGoalTween.setFieldLabel(String) and use that label in your game's code to cancel or complete that tween:
FlixelGoalTween t = (FlixelGoalTween) FlixelTween.tween(myObject, new FlixelTweenSettings()
.addGoal(myObject::getFoo, 100f, myObject::setFoo)
.addGoal(myObject::getBar, 200f, myObject::setBar));
t.setFieldLabel("yourLabel");
// Later in your game's code...
FlixelTween.cancelTweensOf(myObject, "yourLabel");
FlixelTween.completeTweensOf(myObject, "yourLabel");
See Also: FlixelTweenSettings
Constructors
FlixelGoalTween(FlixelTweenSettings)
Constructs a new goal tween with the given settings. Goals must be added via FlixelTweenSettings.addGoal(...) before starting.
Parameters:
| Name | Description |
|---|---|
settings | The settings that configure and determine how the tween should animate. |
Fields
tweenObject
Logical subject for FlixelGoalTween.isTweenOf(Object, String); must be set before FlixelGoalTween.start() / FlixelTweenManager.addTween(FlixelTween).
fieldLabel
Optional label for FlixelGoalTween.isTweenOf(Object, String) when no intrinsic property name exists.
cachedPropertyGoals
Cached property goals captured at FlixelGoalTween.start() to avoid re-allocating the list every frame inside FlixelGoalTween.updateTweenValues().
propertyGoalStartValues
Initial values of each property goal, captured from their getter at FlixelGoalTween.start(), indexed parallel to FlixelGoalTween.cachedPropertyGoals.
Methods
setObject(Object)
Sets the object this tween logically animates (required before FlixelGoalTween.start()).
This has to be set because FlixelGoalTween.isTweenOf(Object, String) needs to know the object to tween. This method is purely for logic purposes used by FlixelTweenManager, not for tweening purposes.
Parameters:
| Name | Description |
|---|---|
tweenObject | The object to tween. |
Returns: this for chaining.
setFieldLabel(String)
Assigns an optional logical field name used by FlixelGoalTween.isTweenOf(Object, String) when checking whether this tween animates a particular named property.
Parameters:
| Name | Description |
|---|---|
fieldLabel | The field label to associate with this tween, or null to clear any previously set label. |
Returns: This tween instance for method chaining.
getTweenObject()
Returns the logical target object that this tween animates, or null if no object has been set yet.
Returns: The tween target object, or null.
getFieldLabel()
Returns the optional logical field label associated with this tween, or null if none has been set.
Returns: The field label, or null.
start()
updateTweenValues()
restart()
reset()
isTweenOf(Object, String)
Returns whether this tween matches the given object and optional field path.
When field contains no '.', the match requires object identity with FlixelGoalTween.setObject(Object) and, if FlixelGoalTween.setFieldLabel(String) was used, equality between field and that label.
When field is dotted, the framework no longer walks nested objects. Matching succeeds only when o is the same instance as the logical tween object and the segment after the final '.' equals fieldLabel when a label is configured (or any suffix when the label is null). Callers that cancel tweens using a root object and a long dotted path should pass the same object reference that was passed to setObject(...).
Parameters:
| Name | Description |
|---|---|
o | Candidate object from the manager query. |
field | Optional path string (may contain dots). |
Returns: true when this tween should be treated as a match.