Skip to content

Loader should be a custom Scene #600

Closed
@kamranayub

Description

@kamranayub

Context

After #599 is merged, a Loader has update and draw functions and the new PausedAfterLoader even has a child actor that it manually calls update/draw on. A Loader is just a custom Scene at its heart that just can't use resources. There are several problems right now:

  • Loader must manually handle actors it controls
  • There are no lifecycle events for itself or its actors
  • We have to manually handle input when loading vs. letting scene infrastructure take care of it
  • There's custom plumbing to wait for a loader vs. just using scene transitioning/plumbing to do it once load() Promise resolves

Proposal

I propose making Loader an interstitial scene by default and allowing it to be extendable/overridable. It won't be the root scene but it'll be a scene that maybe gets deactivated/removed after it's promise returns. It can extend Scene but implement ILoadable as well. Engine will just need some slight refactoring to accommodate the change but I don't think it'll be difficult.

We could even combine Scene and ILoadable so that goToScene returns a promise that resolves when Scene.load() returns. So Scene just becomes ILoadable and then we have transitions as well. Then the engine could call update/draw but Scene would not update/draw its actors until it's done loading. To try the new API, we could have a new method loadScene(name): Promise<any> that we could expose that would run the loading logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api changeBreaking api changeenhancementLabel applied to enhancements or improvements to existing featuresproposalApplied to issues that are a proposal for an implementationstaleThis issue or PR has not had any activity recently

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions