Skip to content

Expand event system #48

@Auroriax

Description

@Auroriax

This is an undocumented feature for in the latest release (so this may change, use with care!), but PS+ will now throw some events on the document so it becomes easier to listen to those events from native JS code. You can listen to psplusGameStarted, psplusLevelLoaded, and psplusLevelRestarted, with the latter two passing the level number as detail. Ideally I want to expand on this a bit more, by adding more events, deciding from which component to fire the events (probably the canvas instead of the document, and document it properly (also explaining the use cases).

For example, this would fire a console message each time a level was started:

document.addEventListener("psplusLevelLoaded", LevelStartFunction);

function LevelStartFunction(e) {
    var level = e.detail;
    console.log("Wow! You're already at level " + level + "!");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions