Phaser API Documentation


Member of: Phaser.Tweens.Tween

setCallback(type, callback, [params], [scope])


Sets an event based callback to be invoked during playback.

Calling this method will replace a previously set callback for the given type, if any exists.

The types available are:

onActive When the Tween is moved from the pending to the active list in the Tween Manager, even if playback paused. onStart When the Tween starts playing after a delayed state. Will happen at the same time as onActive if it has no delay. onYoyo When a TweenData starts a yoyo. This happens after the hold delay expires, if set. onRepeat When a TweenData repeats playback. This happens after the repeatDelay expires, if set. onComplete When the Tween finishes playback fully or Tween.stop is called. Never invoked if tween is set to repeat infinitely. onUpdate When a TweenData updates a property on a source target during playback. onLoop When a Tween loops. This happens after the loopDelay expires, if set.


name type arguments description
type string

Type of the callback to set.

callback function

The function to invoke when this callback happens.

params array <optional>

An array of parameters for specified callbacks types.

scope any <optional>

The context the callback will be invoked in.


This Tween instance.

Since: 3.0.0