696ff5f2-c791-439d-a6ca-318205f4c37f.js 2.95 KB
"use strict";
cc._RF.push(module, '696ffXyx5FDnabKMYIF9MN/', 'ItemFix');
// script/game/ui/ItemFix.ts

"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
const { ccclass, property } = cc._decorator;
let ItemFix = /** @class */ (() => {
    let ItemFix = class ItemFix extends cc.Component {
        constructor() {
            super(...arguments);
            this.fixHua = false;
            this.fixQiang = false;
            this.fixBiao = false;
            this.fixBen = false;
        }
        start() {
        }
        onLoad() {
            //卧室界面的设计尺寸是620 * 930        
            let parentNodewidth = cc.winSize.width;
            let parentNodeHeight = cc.winSize.height;
            let rW = parentNodewidth / 720;
            let rH = parentNodeHeight / 1280;
            let comp = this.getComponent(cc.Widget);
            let itemHeight = this.node.getChildByName("itemSpr").height;
            let itemWidth = this.node.getChildByName("itemSpr").width;
            if (this.fixHua) {
                comp.top = (parentNodeHeight / 2) - (280 * rH) - (itemHeight * rH / 2);
                if (rH < 1) {
                    this.node.scale = 0.8;
                    comp.left = itemWidth * 0.8 / 2;
                }
                else {
                    comp.left = itemWidth / 2;
                }
            }
            if (this.fixQiang) {
                comp.top = (parentNodeHeight / 2) + 50;
                comp.left = comp.left * rW;
            }
            if (this.fixBiao) {
                comp.right = comp.right * rW;
                comp.bottom = comp.bottom * rH;
            }
            if (this.fixBen) {
                comp.right = comp.right * rW;
                comp.bottom = comp.bottom * rH;
            }
            comp.updateAlignment();
        }
    };
    __decorate([
        property({ tooltip: "是否适配画" })
    ], ItemFix.prototype, "fixHua", void 0);
    __decorate([
        property({ tooltip: "是否适配手枪" })
    ], ItemFix.prototype, "fixQiang", void 0);
    __decorate([
        property({ tooltip: "是否适配手表" })
    ], ItemFix.prototype, "fixBiao", void 0);
    __decorate([
        property({ tooltip: "是否适配笔记本" })
    ], ItemFix.prototype, "fixBen", void 0);
    ItemFix = __decorate([
        ccclass
    ], ItemFix);
    return ItemFix;
})();
exports.default = ItemFix;

cc._RF.pop();