TweenManager

Ticks every live tween once per frame (see Game.tweenManager) and writes interpolated values straight onto arbitrary target object fields - no manual per-frame HandleTween() bookkeeping required. Wraps BGE.Tweens.CreateTweenObject()/HandleTween() per managed tween rather than reimplementing interpolation.


Constructor

new TweenManager(): TweenManager

Instance Methods

to( targetObj: object, destFields: roAssociativeArray, duration: integer, easing?: BGE.Tweens.Easing, options?: roAssociativeArray, ): integer

Tweens one or more fields on target from their current values to destFields' values. target is the sub-object to write onto directly - e.g. an entity's own position Vector, a Drawable, a plain associative array - not the owning entity itself and not a dot-path string.

it's no longer valid), onComplete (a sub(targetObj as object), called once with this tween's target when it retires - not a closure/m-bound callback, since a BrightScript function value can't reliably carry either once detached from its original owner), loop, delay

Parameters

  • targetObj (object)
  • destFields (roAssociativeArray) — {fieldName: destValue, ...}
  • duration (integer) — milliseconds
  • easing (BGE.Tweens.Easing, optional, default: "BGE.Tweens.Easing.LinearTween")
  • options (roAssociativeArray, optional, default: "{}") — owner (GameEntity, for automatic cleanup once

Returns

  • integer — a handle for cancel()

toColorRGB( targetObj: object, fieldName: string, destColor: integer, duration: integer, easing?: BGE.Tweens.Easing, options?: roAssociativeArray, ): integer

Tweens a packed RGB (0xRRGGBB) color field channel-wise - lerping the packed int directly is wrong. Decomposes into R/G/B, tweens each 0-255 channel, and repacks every tick.

Parameters

  • targetObj (object)
  • fieldName (string) — the field on targetObj holding the packed color
  • destColor (integer) — packed 0xRRGGBB
  • duration (integer) — milliseconds
  • easing (BGE.Tweens.Easing, optional, default: "BGE.Tweens.Easing.LinearTween")
  • options (roAssociativeArray, optional, default: "{}") — see to()

Returns

  • integer — a handle for cancel()

toColorRGBA( targetObj: object, fieldName: string, destColor: integer, duration: integer, easing?: BGE.Tweens.Easing, options?: roAssociativeArray, ): integer

Same as toColorRGB() but for a packed RGBA (0xRRGGBBAA) field.

Parameters

  • targetObj (object)
  • fieldName (string) — the field on targetObj holding the packed color
  • destColor (integer) — packed 0xRRGGBBAA
  • duration (integer) — milliseconds
  • easing (BGE.Tweens.Easing, optional, default: "BGE.Tweens.Easing.LinearTween")
  • options (roAssociativeArray, optional, default: "{}") — see to()

Returns

  • integer — a handle for cancel()

cancel(handle: integer): void

Parameters

  • handle (integer)

Returns

  • void

clear(): void

Returns

  • void

update(): void

Ticks every live tween and applies its current interpolated value. Called once per frame by Game - not part of the API a consumer calls directly.

Returns

  • void

onResume(pausedTimeMs: integer): void

Compensates every live tween's timer for a pause of the given duration, mirroring AnimatedImage.onResume() - called by Game.Resume() with the same paused_time it already computes for every entity/drawable's own onResume().

Parameters

  • pausedTimeMs (integer)

Returns

  • void