Skip to content

Commit bd4926f

Browse files
committed
fix few TS declaration issues in the example folder
1 parent 7e16a8c commit bd4926f

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

packages/examples/src/examples/deviceTest/ExampleDeviceTest.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import {
2+
type CanvasRenderer,
23
ColorLayer,
34
Renderable,
45
Text,
6+
type WebGLRenderer,
57
device,
68
game,
79
input,
@@ -23,11 +25,11 @@ class DeviceInfo extends Renderable {
2325
this.anchorPoint.set(0, 0);
2426
}
2527

26-
update() {
28+
override update() {
2729
return true;
2830
}
2931

30-
draw(renderer) {
32+
override draw(renderer: WebGLRenderer | CanvasRenderer) {
3133
// current device orientation ("portrait" or "landscape")
3234
const orientation = device.getScreenOrientation();
3335

packages/examples/src/examples/platformer/gameState.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { TextureAtlas } from "melonjs"; // Replace 'path/to/TextureAtlas' with the actual path to the TextureAtlas class.
2+
13
export const gameState = {
24
/**
35
* object where to store game global scole
@@ -8,5 +10,5 @@ export const gameState = {
810
},
911

1012
// a reference to the texture atlas
11-
texture: null,
13+
texture: undefined as TextureAtlas | undefined,
1214
};

packages/examples/src/examples/platformer/play.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ import { VirtualJoypad } from "./entities/controls";
44
import { gameState } from "./gameState";
55

66
export class PlayScreen extends Stage {
7+
private virtualJoypad?: VirtualJoypad;
8+
private HUD?: UIContainer;
9+
710
/**
811
* action to perform on state change
912
*/
10-
onResetEvent() {
13+
override onResetEvent() {
1114
// load a level
1215
level.load("map1");
1316

@@ -35,16 +38,18 @@ export class PlayScreen extends Stage {
3538
/**
3639
* action to perform on state change
3740
*/
38-
onDestroyEvent() {
41+
override onDestroyEvent() {
3942
// remove the HUD from the game world
40-
game.world.removeChild(this.HUD);
43+
if (this.HUD) {
44+
game.world.removeChild(this.HUD);
45+
}
4146

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

4752
// stop some music
48-
audio.stopTrack("dst-gameforest");
53+
audio.stopTrack();
4954
}
5055
}

0 commit comments

Comments
 (0)