Skip to content

Commit

Permalink
fix few TS declaration issues in the example folder
Browse files Browse the repository at this point in the history
  • Loading branch information
obiot committed Aug 27, 2024
1 parent 7e16a8c commit bd4926f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {
type CanvasRenderer,
ColorLayer,
Renderable,
Text,
type WebGLRenderer,
device,
game,
input,
Expand All @@ -23,11 +25,11 @@ class DeviceInfo extends Renderable {
this.anchorPoint.set(0, 0);
}

update() {
override update() {
return true;
}

draw(renderer) {
override draw(renderer: WebGLRenderer | CanvasRenderer) {
// current device orientation ("portrait" or "landscape")
const orientation = device.getScreenOrientation();

Expand Down
4 changes: 3 additions & 1 deletion packages/examples/src/examples/platformer/gameState.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { TextureAtlas } from "melonjs"; // Replace 'path/to/TextureAtlas' with the actual path to the TextureAtlas class.

export const gameState = {
/**
* object where to store game global scole
Expand All @@ -8,5 +10,5 @@ export const gameState = {
},

// a reference to the texture atlas
texture: null,
texture: undefined as TextureAtlas | undefined,
};
13 changes: 9 additions & 4 deletions packages/examples/src/examples/platformer/play.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import { VirtualJoypad } from "./entities/controls";
import { gameState } from "./gameState";

export class PlayScreen extends Stage {
private virtualJoypad?: VirtualJoypad;
private HUD?: UIContainer;

/**
* action to perform on state change
*/
onResetEvent() {
override onResetEvent() {
// load a level
level.load("map1");

Expand Down Expand Up @@ -35,16 +38,18 @@ export class PlayScreen extends Stage {
/**
* action to perform on state change
*/
onDestroyEvent() {
override onDestroyEvent() {
// remove the HUD from the game world
game.world.removeChild(this.HUD);
if (this.HUD) {
game.world.removeChild(this.HUD);
}

// remove the joypad if initially added
if (this.virtualJoypad && game.world.hasChild(this.virtualJoypad)) {
game.world.removeChild(this.virtualJoypad);
}

// stop some music
audio.stopTrack("dst-gameforest");
audio.stopTrack();
}
}

0 comments on commit bd4926f

Please sign in to comment.