1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- System.register(["cc"], function (_export, _context) {
- "use strict";
- var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Component, find, ResolutionPolicy, screen, Size, size, UITransform, view, _dec, _class, _crd, ccclass, property, CHECK_INTERVAL, ResolutionAutoFit;
- return {
- setters: [function (_cc) {
- _cclegacy = _cc.cclegacy;
- __checkObsolete__ = _cc.__checkObsolete__;
- __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
- _decorator = _cc._decorator;
- Component = _cc.Component;
- find = _cc.find;
- ResolutionPolicy = _cc.ResolutionPolicy;
- screen = _cc.screen;
- Size = _cc.Size;
- size = _cc.size;
- UITransform = _cc.UITransform;
- view = _cc.view;
- }],
- execute: function () {
- _crd = true;
- _cclegacy._RF.push({}, "f237c0rurlJMK37Xb4mkHTf", "ResolutionAutoFit", undefined);
- __checkObsolete__(['_decorator', 'Component', 'find', 'Node', 'ResolutionPolicy', 'screen', 'Size', 'size', 'UITransform', 'view']);
- ({
- ccclass,
- property
- } = _decorator);
- CHECK_INTERVAL = 0.1;
- _export("ResolutionAutoFit", ResolutionAutoFit = (_dec = ccclass('ResolutionAutoFit'), _dec(_class = class ResolutionAutoFit extends Component {
- constructor() {
- super(...arguments);
- this._oldSize = size();
- this.lastCheckTime = 0;
- }
- start() {
- this.adjustResolutionPolicy();
- }
- update(deltaTime) {
- this.lastCheckTime += deltaTime;
- if (this.lastCheckTime < CHECK_INTERVAL) {
- return;
- }
- this.lastCheckTime = 0;
- this.adjustResolutionPolicy();
- }
- adjustResolutionPolicy() {
- var winSize = screen.windowSize;
- if (!this._oldSize.equals(winSize)) {
- var ratio = winSize.width / winSize.height;
- var drs = view.getDesignResolutionSize();
- var drsRatio = drs.width / drs.height;
- var splash = find("Canvas/SpriteSplash");
- if (splash) {
- splash.getComponent(UITransform).contentSize = new Size(drs.width, drs.height);
- }
- if (ratio > drsRatio) {
- //wider than desgin. fixed height
- view.setResolutionPolicy(ResolutionPolicy.FIXED_HEIGHT);
- } else {
- //
- view.setResolutionPolicy(ResolutionPolicy.FIXED_WIDTH);
- }
- this._oldSize.set(winSize);
- }
- }
- }) || _class));
- _cclegacy._RF.pop();
- _crd = false;
- }
- };
- });
- //# sourceMappingURL=e57b803267a903f9e1b0a0c341b2dec3d5f19f37.js.map
|