-
-
Notifications
You must be signed in to change notification settings - Fork 657
Refactor Tween to use event-based lifecycle instead of world container #1347
Copy link
Copy link
Open
Description
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
TICKevent instead of relying on the container'supdate()cycle - Timing: listen to
GAME_AFTER_UPDATEfor the latest game loop timestamp (already implemented) - Pause/Resume: listen to
STATE_PAUSE/STATE_RESUMEevents - Cleanup: listen to
GAME_RESETfor 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.worldglobal - 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
Tweenwill no longer be aRenderable— 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels