MCPcopy Create free account
hub / github.com/melonjs/melonJS / onResetEvent

Method onResetEvent

packages/examples/src/examples/platformer/play.ts:28–64  ·  view source on GitHub ↗

* action to perform on state change

(app: Application)

Source from the content-addressed store, hash-verified

26 * action to perform on state change
27 */
28 override onResetEvent(app: Application) {
29 // load a level
30 level.load("map1");
31
32 // add a minimap camera (reuse if already present)
33 if (!this.cameras.has("minimap")) {
34 this.cameras.set("minimap", new MinimapCamera());
35 }
36
37 // reset the score
38 gameState.data.score = 0;
39
40 // add our HUD to the game world
41 if (typeof this.HUD === "undefined") {
42 this.HUD = new UIContainer();
43 }
44 app.world.addChild(this.HUD);
45
46 // display if debugPanel is enabled or on mobile
47 if (plugin.cache.debugPanel?.panel.visible || device.touch) {
48 if (typeof this.virtualJoypad === "undefined") {
49 this.virtualJoypad = new VirtualJoypad();
50 }
51 app.world.addChild(this.virtualJoypad);
52 }
53
54 // vignette post-effect + built-in color grading (always applied last).
55 // VignetteEffect is WebGL-only; on the Canvas renderer just skip it
56 // and let the color grading still apply.
57 if (app.renderer instanceof WebGLRenderer) {
58 app.viewport.addPostEffect(new VignetteEffect(app.renderer));
59 }
60 app.viewport.colorMatrix.contrast(1.1).saturate(1.1);
61
62 // play some music
63 audio.playTrack("dst-gameforest");
64 }
65
66 /**
67 * action to perform on state change

Callers

nothing calls this directly

Calls 6

addChildMethod · 0.80
addPostEffectMethod · 0.80
hasMethod · 0.45
setMethod · 0.45
saturateMethod · 0.45
contrastMethod · 0.45

Tested by

no test coverage detected