mirror of
https://github.com/danbulant/heaventaker
synced 2026-07-05 19:20:35 +00:00
sizing changes
This commit is contained in:
parent
067ae8200c
commit
af3d6ac071
5 changed files with 29 additions and 5 deletions
|
|
@ -2,6 +2,7 @@ html, body {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,17 @@
|
||||||
outerHeight = window.outerHeight;
|
outerHeight = window.outerHeight;
|
||||||
outerWidth = window.outerWidth;
|
outerWidth = window.outerWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clicked() {
|
||||||
|
startPlaying();
|
||||||
|
|
||||||
|
if(window.innerHeight < 768) {
|
||||||
|
document.body.requestFullscreen({ navigationUI: "hide" });
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window on:click={startPlaying} on:resize={resize} on:keydown={startPlaying} />
|
<svelte:window on:click={clicked} on:resize={resize} on:keydown={startPlaying} />
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>Heaventaker</title>
|
<title>Heaventaker</title>
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,25 @@ import { CANVAS, Game, Scale, WEBGL } from "phaser";
|
||||||
import { GameScene } from "./gameScene";
|
import { GameScene } from "./gameScene";
|
||||||
import { maps } from "./maps";
|
import { maps } from "./maps";
|
||||||
|
|
||||||
|
var ratio = window.devicePixelRatio || 1;
|
||||||
export function resize() {
|
export function resize() {
|
||||||
|
if(!game || !htmlcanvas) return;
|
||||||
|
try {
|
||||||
|
// game.scale.resize(htmlcanvas.parentElement.width * ratio, htmlcanvas.parentElement.height * ratio);
|
||||||
|
} catch(e) {
|
||||||
|
console.error(e, new ErrorEvent(e.type, {
|
||||||
|
colno: e.colno,
|
||||||
|
error: e,
|
||||||
|
lineno: e.lineno,
|
||||||
|
message: e.message,
|
||||||
|
filename: e.filename
|
||||||
|
}));
|
||||||
|
window.dispatchEvent(new ErrorEvent("error", e));
|
||||||
|
}
|
||||||
|
console.log("size", htmlcanvas.parentElement.clientWidth * ratio, htmlcanvas.parentElement.clientHeight * ratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @type {HTMLCanvasElement} */
|
||||||
var htmlcanvas;
|
var htmlcanvas;
|
||||||
/** @type {Game} */
|
/** @type {Game} */
|
||||||
var game;
|
var game;
|
||||||
|
|
@ -22,8 +37,8 @@ export function setCanvas(canvas) {
|
||||||
type: ctx ? WEBGL : CANVAS,
|
type: ctx ? WEBGL : CANVAS,
|
||||||
context: ctx || canvas.getContext("2d"),
|
context: ctx || canvas.getContext("2d"),
|
||||||
customEnvironment: false,
|
customEnvironment: false,
|
||||||
width: canvas.parentElement.clientWidth,
|
width: window.innerWidth * ratio,
|
||||||
height: canvas.parentElement.clientHeight,
|
height: window.innerHeight * ratio,
|
||||||
scale: {
|
scale: {
|
||||||
mode: Scale.RESIZE
|
mode: Scale.RESIZE
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -61,5 +61,6 @@
|
||||||
width: calc(100vw - 40px);
|
width: calc(100vw - 40px);
|
||||||
height: calc(100vh - 40px);
|
height: calc(100vh - 40px);
|
||||||
z-index: 999;
|
z-index: 999;
|
||||||
|
overflow: auto;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
console.log("Started");
|
console.log("Started");
|
||||||
setMap(dialog[current].map);
|
setMap(dialog[current].map);
|
||||||
setCanvas(canvas);
|
setCanvas(canvas);
|
||||||
resize();
|
|
||||||
return () => {
|
return () => {
|
||||||
console.log("Stopped");
|
console.log("Stopped");
|
||||||
stop();
|
stop();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue