WardrobeViewFix.ts
1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { DummyNode } from "../../common/CCDummyObjects";
const { ccclass, property } = cc._decorator;
@ccclass
export default class WardrobeViewFix extends cc.Component {
@property({ type: cc.Node, displayName: "Title node" })
titleNode: cc.Node = DummyNode;
@property({ type: cc.Node, displayName: "Wardrobe root node" })
wardrobeRootNode: cc.Node = DummyNode;
@property({ type: cc.Node, displayName: "Suit tab root node" })
suitTabRootNode: cc.Node = DummyNode;
@property({ type: cc.Node, displayName: "Introduction node" })
introductionNode: cc.Node = DummyNode;
onLoad() {
//界面设计尺寸为720*1080
let originalWigth = 720;
let originalHeight = 1080;
let originalProportion = originalHeight / originalWigth;
let actualWidth = cc.winSize.width;
let actualHeight = cc.winSize.height;
let actualProportion = actualHeight / actualWidth;
let titleNodeWidget = this.titleNode.getComponent(cc.Widget);
let suitTabRootNodeWidget = this.suitTabRootNode.getComponent(cc.Widget);
let introductionNodeWidget = this.introductionNode.getComponent(cc.Widget);
if (actualProportion >= 1.9) {
titleNodeWidget.verticalCenter = 590;
titleNodeWidget.updateAlignment();
suitTabRootNodeWidget.verticalCenter = -600;
suitTabRootNodeWidget.updateAlignment();
introductionNodeWidget.top = 200;
introductionNodeWidget.updateAlignment();
}
if (actualProportion <= 1.5) {
titleNodeWidget.verticalCenter = 370;
titleNodeWidget.updateAlignment();
suitTabRootNodeWidget.verticalCenter = -390;
suitTabRootNodeWidget.updateAlignment();
introductionNodeWidget.top = 100;
introductionNodeWidget.updateAlignment();
this.wardrobeRootNode.scale = 0.7;
}
}
}