feat:resize时自定义画布可执行事件

This commit is contained in:
ShakeFlower 2026-02-23 15:55:39 +08:00
parent cb745b6acc
commit 98783c3585

View File

@ -19,6 +19,8 @@ control.prototype._init = function () {
this.weathers = {};
this.resizes = [];
this.noAutoEvents = true;
/** @type {{[canvasName:string]:Function}} */
this.dymCanvasResizeEvents = {};
// --- 注册系统的animationFrame
this.registerAnimationFrame("totalTime", false, this._animationFrame_totalTime);
this.registerAnimationFrame("autoSave", true, this._animationFrame_autoSave);
@ -3638,6 +3640,14 @@ control.prototype._resize_gameGroup = function (obj) {
}
}
control.prototype.registerDymCanvasResizeEvent = function (name, event){
this.dymCanvasResizeEvents[name] = event;
}
control.prototype.unregisterDymCanvasResizeEvent = function (name){
delete this.dymCanvasResizeEvents[name];
}
control.prototype._resize_canvas = function (obj) {
var innerSize = (obj.CANVAS_WIDTH * core.domStyle.scale) + "px";
if (!core.isPlaying()) {
@ -3681,6 +3691,10 @@ control.prototype._resize_canvas = function (obj) {
canvas.style.left = parseFloat(canvas.getAttribute("_left")) * core.domStyle.scale + "px";
canvas.style.top = parseFloat(canvas.getAttribute("_top")) * core.domStyle.scale + "px";
}
if (this.dymCanvasResizeEvents[name]) {
const event = this.dymCanvasResizeEvents[name];
event();
}
}
// resize next
main.dom.next.style.width = main.dom.next.style.height = 5 * core.domStyle.scale + "px";