15 lines
351 B
15 lines
351 B
3 months ago
|
//宽度自适应
|
||
|
const {ccclass, property} = cc._decorator;
|
||
|
|
||
|
@ccclass
|
||
|
export default class WidthAdaptor extends cc.Component {
|
||
|
|
||
|
protected onLoad(): void {
|
||
|
|
||
|
let canvas = cc.Canvas.instance;
|
||
|
let ratioWidth = cc.visibleRect.width / canvas.designResolution.width;
|
||
|
this.node.scale = ratioWidth * this.node.scale;
|
||
|
}
|
||
|
|
||
|
}
|