Scale game window outside cordova

This commit is contained in:
OleSTEEP 2024-02-14 20:45:02 +03:00
parent 06ff99769d
commit aba41086e7
2 changed files with 24 additions and 28 deletions

View file

@ -141,25 +141,23 @@ StreamWebAudio.prototype._onCordovaResume = function () {
document.addEventListener("backbutton", function(event){
event.preventDefault();
});
});
// =====================
// Scale game canvas
// =====================
document.addEventListener("deviceready", () => {
Graphics._updateRealScale = function () {
if (this._stretchEnabled) {
var h = window.innerWidth / this._width;
var v = window.innerHeight / this._height;
if (h >= 1 && h - 0.01 <= 1) h = 1;
if (v >= 1 && v - 0.01 <= 1) v = 1;
this._realScale = Math.min(h, v);
} else {
this._realScale = this._scale;
}
};
})
Graphics._updateRealScale = function () {
if (this._stretchEnabled) {
var h = window.innerWidth / this._width;
var v = window.innerHeight / this._height;
if (h >= 1 && h - 0.01 <= 1) h = 1;
if (v >= 1 && v - 0.01 <= 1) v = 1;
this._realScale = Math.min(h, v);
} else {
this._realScale = this._scale;
}
};
// ===========================
// Gamepad tips on default

View file

@ -141,25 +141,23 @@ StreamWebAudio.prototype._onCordovaResume = function () {
document.addEventListener("backbutton", function(event){
event.preventDefault();
});
});
// =====================
// Scale game canvas
// =====================
document.addEventListener("deviceready", () => {
Graphics._updateRealScale = function () {
if (this._stretchEnabled) {
var h = window.innerWidth / this._width;
var v = window.innerHeight / this._height;
if (h >= 1 && h - 0.01 <= 1) h = 1;
if (v >= 1 && v - 0.01 <= 1) v = 1;
this._realScale = Math.min(h, v);
} else {
this._realScale = this._scale;
}
};
})
Graphics._updateRealScale = function () {
if (this._stretchEnabled) {
var h = window.innerWidth / this._width;
var v = window.innerHeight / this._height;
if (h >= 1 && h - 0.01 <= 1) h = 1;
if (v >= 1 && v - 0.01 <= 1) v = 1;
this._realScale = Math.min(h, v);
} else {
this._realScale = this._scale;
}
};
// ===========================
// Gamepad tips on default