Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Excalibur Scene Transitions & Loaders #2790

Merged
merged 71 commits into from
Jan 14, 2024
Merged

Conversation

eonarheim
Copy link
Member

@eonarheim eonarheim commented Oct 10, 2023

===:clipboard: PR Checklist :clipboard:===

  • 📌 issue exists in github for these changes
  • 🔬 existing tests still pass
  • 🙈 code conforms to the style guide
  • 📐 new tests written and passing / old tests updated with new scenario(s)
  • 📄 changelog entry added (or not needed)

==================

This PR implements an API inspired by https://github.com/mattjennings/excalibur-router/ with permission from Matt.

The idea behind this refactoring is to add transitions between scenes and scene specific loaders!

  • Add or remove scenes by constructor
  • Add loaders by constructor
  • New DefaultLoader type that allows for easier custom loader creation
  • New Transition type for building custom transitions
  • New scene lifecycle to allow scene specific resource loading
    • onTransition(direction: "in" | "out") {...}
    • onPreLoad(loader: DefaultLoader) {...}
  • New async goto API that allows overriding loaders/transitions between scenes
  • Scenes now can have async onInitialize and async onActivate!
  • New scenes director API that allows upfront definition of scenes/transitions/loaders

View this file for a current example of what the API looks like

Defining scenes upfront

const game = new ex.Engine({
  scenes: {
    scene1: {
      scene: scene1,
      transitions: {
        out: new ex.FadeInOut({duration: 1000, direction: 'out', color: ex.Color.Black}),
        in: new ex.FadeInOut({duration: 1000, direction: 'in'})
      }
    },
    scene2: {
      scene: scene2,
      loader: ex.DefaultLoader, // Constructor only option!
      transitions: {
        out: new ex.FadeInOut({duration: 1000, direction: 'out'}),
        in: new ex.FadeInOut({duration: 1000, direction: 'in', color: ex.Color.Black })
      }
    },
   scene3: ex.Scene // Constructor only option!
  } 
})

game.start('scene1',
{
  inTransition: new ex.FadeInOut({duration: 500, direction: 'in', color: ex.Color.ExcaliburBlue})
  loader: boot,
});

scene-transitions-loader

@github-actions github-actions bot added the enhancement Label applied to enhancements or improvements to existing features label Oct 10, 2023
Copy link

This PR hasn't had any recent activity lately and is being marked as stale automatically.

@github-actions github-actions bot added the stale This issue or PR has not had any activity recently label Dec 12, 2023
@eonarheim eonarheim merged commit bdaf7d1 into main Jan 14, 2024
4 of 5 checks passed
@eonarheim eonarheim deleted the feat/async-init-ex-router branch January 14, 2024 12:19
@eonarheim
Copy link
Member Author

Woooo! Finally!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Label applied to enhancements or improvements to existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants