Class Effect
- java.lang.Object
-
- nl.colorize.multimedialib.scene.Effect
-
- All Implemented Interfaces:
Renderable,Updatable
public abstract class Effect extends java.lang.Object implements Updatable, Renderable
An animated graphical effect that can be played as part of a scene. In combination with theEffectManager, this allows declarative effects that can be played without having to manually update their logic and graphics every frame.The effect consists of the graphics that are animated according to the timeline. A number of modifiers can be added to the effect, that will use the timeline's current value to update how the effect should be displayed. These modifiers are represented by callback functions, that are called every frame based on the timeline's current value. The effect's graphics are then rendered based on its updated state.
There are two types of effects that can be created using the factory methods in this class. The first are "plain" effects that do not define any behavior. The second are shorthand versions, for example to move a sprite or to change text's alpha value. Note that these shorthand effects can still be extended by adding additional modifiers, so that more complex effects can be created from these starting points.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static EffectforAnimation(Animation anim, nl.colorize.util.animation.Timeline timeline)static EffectforImage(Image image, nl.colorize.util.animation.Timeline timeline)static EffectforSprite(Sprite sprite, nl.colorize.util.animation.Timeline timeline)static EffectforSpriteAlpha(Sprite sprite, nl.colorize.util.animation.Timeline timeline)Shorthand for creating an effect that modifies the sprite's alpha value based on a timeline.static EffectforSpriteRotation(Sprite sprite, float duration)Shorthand for creating an effect that rotates a sprite.static EffectforSpriteX(Sprite sprite, nl.colorize.util.animation.Timeline timeline)Shorthand for creating an effect that modifies the sprite's X position based on a timeline.static EffectforSpriteY(Sprite sprite, nl.colorize.util.animation.Timeline timeline)Shorthand for creating an effect that modifies the sprite's Y position based on a timeline.static EffectforText(java.lang.String text, TTFont font, Align align, nl.colorize.util.animation.Timeline timeline)static EffectforTextAlpha(java.lang.String text, TTFont font, Align align, nl.colorize.util.animation.Timeline timeline)Shorthand for creating an effect that modifies the text's alpha value based on a timeline.static EffectforTextAppear(java.lang.String text, TTFont font, Align align, float duration)Shorthand for creating an effect that will make the text slowly appear over time, with more and more characters appearing on screen over time until the entire text is shown.PointgetPosition()TransformgetTransform()booleanisCompleted()voidmodify(java.util.function.Consumer<java.lang.Float> modifier)Registers a callback function that will be called during every frame update, with the effect's current timeline value as the argument.abstract voidrender(GraphicsContext graphics)voidsetPosition(float x, float y)voidsetPosition(Point position)voidsetTransform(Transform transform)voidupdate(float deltaTime)Updates this object for the current frame.
-
-
-
Method Detail
-
modify
public void modify(java.util.function.Consumer<java.lang.Float> modifier)
Registers a callback function that will be called during every frame update, with the effect's current timeline value as the argument. The callback can then be used to update the effect's graphical appearance.
-
setPosition
public void setPosition(Point position)
-
setPosition
public void setPosition(float x, float y)
-
getPosition
public Point getPosition()
-
setTransform
public void setTransform(Transform transform)
-
getTransform
public Transform getTransform()
-
update
public void update(float deltaTime)
Description copied from interface:UpdatableUpdates this object for the current frame.
-
isCompleted
public boolean isCompleted()
-
render
public abstract void render(GraphicsContext graphics)
- Specified by:
renderin interfaceRenderable
-
forSprite
public static Effect forSprite(Sprite sprite, nl.colorize.util.animation.Timeline timeline)
-
forSpriteX
public static Effect forSpriteX(Sprite sprite, nl.colorize.util.animation.Timeline timeline)
Shorthand for creating an effect that modifies the sprite's X position based on a timeline.
-
forSpriteY
public static Effect forSpriteY(Sprite sprite, nl.colorize.util.animation.Timeline timeline)
Shorthand for creating an effect that modifies the sprite's Y position based on a timeline.
-
forSpriteRotation
public static Effect forSpriteRotation(Sprite sprite, float duration)
Shorthand for creating an effect that rotates a sprite.
-
forSpriteAlpha
public static Effect forSpriteAlpha(Sprite sprite, nl.colorize.util.animation.Timeline timeline)
Shorthand for creating an effect that modifies the sprite's alpha value based on a timeline.
-
forAnimation
public static Effect forAnimation(Animation anim, nl.colorize.util.animation.Timeline timeline)
-
forText
public static Effect forText(java.lang.String text, TTFont font, Align align, nl.colorize.util.animation.Timeline timeline)
-
forTextAppear
public static Effect forTextAppear(java.lang.String text, TTFont font, Align align, float duration)
Shorthand for creating an effect that will make the text slowly appear over time, with more and more characters appearing on screen over time until the entire text is shown.
-
-