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

loading of assets after ready() #41

Open
oberhamsi opened this issue Jan 16, 2012 · 1 comment
Open

loading of assets after ready() #41

oberhamsi opened this issue Jan 16, 2012 · 1 comment
Labels

Comments

@oberhamsi
Copy link
Member

currently only one set of assets can be preloaded before ready() is executed. for large games it would be useful to be able to load additional resources after the game is already initialized (e.g. for loading the next map assets).

API RFC

calling preload() after initialization triggers another async preloader. Once all assets were loaded, an event PRELOAD_SUCCESS or PRELOAD_ERROR is triggered.

the preloadId returned by preload() and in the resulting event is there, in case the game triggers multiple preload()s and needs to differantiate which one was finished:

// in game code:
var preloadId = gamejs.preload(['./images/foo.png']);

// in event handler:
if (event.type === gamejs.event.PRELOAD_SUCCESS) {
       gamejs.log('Loaded assets ', event.preloadId);
}
@systemstart
Copy link
Contributor

sounds good.

maybe let preload return an object which can be queried for progress and which emits success/error event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants