Waterfall Size Animation

It's possible to animate the waterfall size in code using the method AnimateWaterfallSize(targetSize, duration, constraint, wrapMode).

  • targetSize: [Vector2] sets the waterfall target size.
  • duration: [float] sets the animation duration in seconds.
  • constraint: [enum WaterAnimationConstraint] constraints the position of one/multiple waterfall edge(s)

    WaterAnimationConstraint enum

    None, Top, Bottom, Left, Right, TopLeft, TopRight, BottomLeft, BottomRight

    • wrapMode: [enum WaterAnimationWrapMode]

    WaterAnimationWrapMode enum

    • Once: Stops playing the animation once the target size is reached.
    • Loop: The water size is reset to the initial size and the animation is restarted once the target size is reached.
    • PingPong: When the target size is reached, the initial size is set to the new target size and the animation restarts. So the waterfall size will ping-pong back and forth between the initial size and the target size.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
using Game2DWaterKit.Animation;

....

var targetSize = waterfallObject.MainModule.WaterfallSize + new Vector2(0f, 3f); // increase the waterfall height by 3 units
var duration = 2f; // 2 seconds
var constraint = WaterAnimationConstraint.Bottom; // constraints the position of the bottom edges, so only the top edge "moves"
var wrapMode = WaterAnimationWrapMode.Once; // play the animation once

waterfallObject.AnimationModule.AnimateWaterfallSize(targetSize, duration, constraint, wrapMode);