mirror of
https://github.com/danbulant/heaventaker
synced 2026-06-20 23:21:08 +00:00
map switching
This commit is contained in:
parent
f4b51f6264
commit
b56c53b025
2 changed files with 22 additions and 1 deletions
|
|
@ -32,6 +32,14 @@ export class GameScene extends Phaser.Scene {
|
|||
steps.set(map.steps);
|
||||
}
|
||||
|
||||
unload() {
|
||||
this.grid.destroy();
|
||||
this.background.destroy();
|
||||
this.container.destroy();
|
||||
delete this.items;
|
||||
delete this.winds;
|
||||
}
|
||||
|
||||
preload() {
|
||||
this.load.setBaseURL();
|
||||
this.load.image("level1", "/sprite/level1.webp");
|
||||
|
|
@ -49,6 +57,10 @@ export class GameScene extends Phaser.Scene {
|
|||
this.game.sound.context.resume();
|
||||
}
|
||||
});
|
||||
this.createMap();
|
||||
}
|
||||
|
||||
createMap() {
|
||||
console.log(this.map);
|
||||
|
||||
this.container = this.add.container();
|
||||
|
|
|
|||
|
|
@ -9,9 +9,12 @@ export function resize() {
|
|||
var htmlcanvas;
|
||||
/** @type {Game} */
|
||||
var game;
|
||||
/** @type {GameScene} */
|
||||
var gs;
|
||||
export function setCanvas(canvas) {
|
||||
htmlcanvas = canvas;
|
||||
var ctx = canvas.getContext("webgl2") || canvas.getContext("webgl");
|
||||
gs = new GameScene(map);
|
||||
game = new Game({
|
||||
canvas: canvas,
|
||||
url: window.location.host,
|
||||
|
|
@ -29,7 +32,7 @@ export function setCanvas(canvas) {
|
|||
},
|
||||
title: "Heaventaker",
|
||||
version: "beta",
|
||||
scene: [new GameScene(map)],
|
||||
scene: [gs],
|
||||
backgroundColor: "#01021B"
|
||||
});
|
||||
game.hideBanner = true;
|
||||
|
|
@ -45,4 +48,10 @@ var mapname;
|
|||
export function setMap(newmap) {
|
||||
mapname = newmap;
|
||||
map = maps[mapname];
|
||||
if(gs) {
|
||||
gs.unload();
|
||||
gs.map = map;
|
||||
gs.createMap();
|
||||
}
|
||||
console.log("Loaded map", mapname);
|
||||
}
|
||||
Loading…
Reference in a new issue