Skip to content

Added preloader to avoid network calls and computationally expensive scaling between scenes#55

Open
VictorSohier wants to merge 3 commits intomainfrom
sohier/preloader
Open

Added preloader to avoid network calls and computationally expensive scaling between scenes#55
VictorSohier wants to merge 3 commits intomainfrom
sohier/preloader

Conversation

@VictorSohier
Copy link
Copy Markdown
Member

Changes:

Added a preload function to scenes.
This is meant to load all assets into memory before the program runs.

Closes #48

How to use

In a given scene class:

  • Write a preload function
  • have the function return an array of promises

How to test this PR:

  1. Run the site
  2. Open the network profiler (typically Ctrl+Shift+i)
  3. Refresh the page

If this solution does as I say it does, all assets for the cheatsheet and challenge mode pages should not be loaded on scene switch, but instead, on page load.

Checklist:

  • tested locally
  • added tests if needed
  • linked the associated ticket
  • assigned yourself to this PR

@VictorSohier VictorSohier self-assigned this Aug 29, 2021
setup() {}
preload()
{
let promises = [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this be made redundant by GateFactory.preload() in #51 ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it will, it is basically all thrown into the gate factory preloader, that mess is for demonstration purposes.

{
canvasManager.createCanvas();
sceneManager.setCurrentScene(MAIN_MENU);
let promises = [];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a lot of noise in this PR, is this the heart of the changes you're making here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write Preloader

2 participants