File tree 3 files changed +16
-7
lines changed
packages/examples/src/examples
3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change 1
1
import {
2
+ type CanvasRenderer ,
2
3
ColorLayer ,
3
4
Renderable ,
4
5
Text ,
6
+ type WebGLRenderer ,
5
7
device ,
6
8
game ,
7
9
input ,
@@ -23,11 +25,11 @@ class DeviceInfo extends Renderable {
23
25
this . anchorPoint . set ( 0 , 0 ) ;
24
26
}
25
27
26
- update ( ) {
28
+ override update ( ) {
27
29
return true ;
28
30
}
29
31
30
- draw ( renderer ) {
32
+ override draw ( renderer : WebGLRenderer | CanvasRenderer ) {
31
33
// current device orientation ("portrait" or "landscape")
32
34
const orientation = device . getScreenOrientation ( ) ;
33
35
Original file line number Diff line number Diff line change
1
+ import type { TextureAtlas } from "melonjs" ; // Replace 'path/to/TextureAtlas' with the actual path to the TextureAtlas class.
2
+
1
3
export const gameState = {
2
4
/**
3
5
* object where to store game global scole
@@ -8,5 +10,5 @@ export const gameState = {
8
10
} ,
9
11
10
12
// a reference to the texture atlas
11
- texture : null ,
13
+ texture : undefined as TextureAtlas | undefined ,
12
14
} ;
Original file line number Diff line number Diff line change @@ -4,10 +4,13 @@ import { VirtualJoypad } from "./entities/controls";
4
4
import { gameState } from "./gameState" ;
5
5
6
6
export class PlayScreen extends Stage {
7
+ private virtualJoypad ?: VirtualJoypad ;
8
+ private HUD ?: UIContainer ;
9
+
7
10
/**
8
11
* action to perform on state change
9
12
*/
10
- onResetEvent ( ) {
13
+ override onResetEvent ( ) {
11
14
// load a level
12
15
level . load ( "map1" ) ;
13
16
@@ -35,16 +38,18 @@ export class PlayScreen extends Stage {
35
38
/**
36
39
* action to perform on state change
37
40
*/
38
- onDestroyEvent ( ) {
41
+ override onDestroyEvent ( ) {
39
42
// remove the HUD from the game world
40
- game . world . removeChild ( this . HUD ) ;
43
+ if ( this . HUD ) {
44
+ game . world . removeChild ( this . HUD ) ;
45
+ }
41
46
42
47
// remove the joypad if initially added
43
48
if ( this . virtualJoypad && game . world . hasChild ( this . virtualJoypad ) ) {
44
49
game . world . removeChild ( this . virtualJoypad ) ;
45
50
}
46
51
47
52
// stop some music
48
- audio . stopTrack ( "dst-gameforest" ) ;
53
+ audio . stopTrack ( ) ;
49
54
}
50
55
}
You can’t perform that action at this time.
0 commit comments