Skip to main content

FlixelShakeTween

View source

class

org.flixelgdx.tween.type.FlixelShakeTween

public class FlixelShakeTween extends FlixelTween

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)

public FlixelShakeTween(FlixelTweenSettings settings)

Fields

target

protected FlixelShakeable target

axes

protected FlixelAxes axes

shakeUnit

protected FlixelShakeUnit shakeUnit

intensity

protected float intensity

savedX

protected float savedX

savedY

protected float savedY

fadeOut

protected boolean fadeOut

Methods

setShake(FlixelShakeable, FlixelAxes, float)

public FlixelShakeTween setShake(FlixelShakeable target, FlixelAxes axes, float intensity)

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:

NameDescription
targetThe object whose shake channel is jittered.
axesWhich axes receive random offset.
intensityWith 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)

public FlixelShakeTween setShakeUnit(FlixelShakeUnit shakeUnit)

Sets how FlixelShakeTween.intensity is interpreted. Default is FlixelShakeUnit.FRACTION.

Returns: this tween for chaining.


setFadeOut(boolean)

public FlixelShakeTween setFadeOut(boolean fadeOut)

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()

public FlixelShakeUnit getShakeUnit()

isFadeOut()

public boolean isFadeOut()

getFadeOut()

public boolean getFadeOut()

Returns whether this shake tween fades out over time.


start()

public FlixelTween start()

updateTweenValues()

protected void updateTweenValues()

reset()

public void reset()

restoreShake()

protected void restoreShake()

cancel()

public FlixelTween cancel()

isTweenOf(Object, String)

public boolean isTweenOf(Object object, String field)