Description
Currently, Tween extends Renderable and adds itself to game.world on start() to participate in the update loop. This is a workaround — tweens are not renderables, they are pure logic objects that interpolate values over time.
This approach creates an unnecessary dependency on the global game.world and makes tweens appear in the scene graph where they don't belong.
Proposed Solution
Tween should use the existing event system for lifecycle management instead of being a child of the world container:
- Update: listen to
TICK event instead of relying on the container's update() cycle
- Timing: listen to
GAME_AFTER_UPDATE for the latest game loop timestamp (already implemented)
- Pause/Resume: listen to
STATE_PAUSE / STATE_RESUME events
- Cleanup: listen to
GAME_RESET for auto-cleanup when the game resets
On start(), the tween subscribes to these events. On stop() or completion, it unsubscribes. No more game.world.addChild(this) / game.world.removeChildNow(this).
Benefits
- Tween no longer extends Renderable (it's not a renderable)
- Removes dependency on
game.world global
- Cleaner separation of concerns — tweens are logic, not scene graph nodes
- Compatible with the Application-as-entry-point architecture
- Simpler mental model for users
Breaking Changes
Tween will no longer be a Renderable — code that relies on tween being in the world container tree would need updating
- Internal change, public tween API (
to(), start(), stop(), onComplete(), etc.) remains the same
Description
Currently,
TweenextendsRenderableand adds itself togame.worldonstart()to participate in the update loop. This is a workaround — tweens are not renderables, they are pure logic objects that interpolate values over time.This approach creates an unnecessary dependency on the global
game.worldand makes tweens appear in the scene graph where they don't belong.Proposed Solution
Tween should use the existing event system for lifecycle management instead of being a child of the world container:
TICKevent instead of relying on the container'supdate()cycleGAME_AFTER_UPDATEfor the latest game loop timestamp (already implemented)STATE_PAUSE/STATE_RESUMEeventsGAME_RESETfor auto-cleanup when the game resetsOn
start(), the tween subscribes to these events. Onstop()or completion, it unsubscribes. No moregame.world.addChild(this)/game.world.removeChildNow(this).Benefits
game.worldglobalBreaking Changes
Tweenwill no longer be aRenderable— code that relies on tween being in the world container tree would need updatingto(),start(),stop(),onComplete(), etc.) remains the same