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 + "!");
}
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
documentso it becomes easier to listen to those events from native JS code. You can listen topsplusGameStarted,psplusLevelLoaded, andpsplusLevelRestarted, with the latter two passing the level number asdetail. 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 thedocument, and document it properly (also explaining the use cases).For example, this would fire a console message each time a level was started: