FlixelShakeTween
View sourceclass
org.flixelgdx.tween.type.FlixelShakeTween
Random shake applied to a FlixelShakeable target by jittering its shake channel (for example sprite graphic offset or world position) around values captured at FlixelShakeTween.start(). Values are restored on FlixelShakeTween.reset(), FlixelShakeTween.cancel(), and when the tween is pooled.
Intensity can be interpreted as a fraction of FlixelShakeable.getShakeWidth() / FlixelShakeable.getShakeHeight() (HaxeFlixel-style when those return positive sizes), or as plain pixels (Unity or Godot style). When FlixelShakeUnit.FRACTION is used and a size hook returns 0 or less on an axis, that axis falls back to treating intensity like FlixelShakeUnit.PIXELS. Use FlixelShakeTween.setShakeUnit(FlixelShakeUnit) and FlixelShakeTween.setFadeOut(boolean) to configure behavior after FlixelShakeTween.setShake(...) or alongside it.
Constructors
FlixelShakeTween(FlixelTweenSettings)
Fields
target
axes
shakeUnit
intensity
savedX
savedY
fadeOut
Methods
setShake(FlixelShakeable, FlixelAxes, float)
Sets target, axes, and intensity. Does not change FlixelShakeTween.shakeUnit or FlixelShakeTween.fadeOut; those stay at defaults from FlixelShakeTween.reset() (FlixelShakeUnit.FRACTION, fade out false) until you set them with FlixelShakeTween.setShakeUnit(FlixelShakeUnit) or FlixelShakeTween.setFadeOut(boolean). Call order is free: you may chain before or after this method.
Parameters:
| Name | Description |
|---|---|
target | The object whose shake channel is jittered. |
axes | Which axes receive random offset. |
intensity | With FlixelShakeUnit.FRACTION and positive FlixelShakeable.getShakeWidth() / FlixelShakeable.getShakeHeight(), use a small value (for example 0.05f). With FlixelShakeUnit.PIXELS, use half-range in pixels. |
Returns: this tween for chaining.
setShakeUnit(FlixelShakeUnit)
Sets how FlixelShakeTween.intensity is interpreted. Default is FlixelShakeUnit.FRACTION.
Returns: this tween for chaining.
setFadeOut(boolean)
When true, shake strength tapers to zero as the tween progresses (scale toward 1). When false, each frame uses the full random range until the tween ends.
Returns: this tween for chaining.
getShakeUnit()
isFadeOut()
getFadeOut()
Returns whether this shake tween fades out over time.