Skip to content

loading of assets after ready() #41

Open
@oberhamsi

Description

@oberhamsi

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions