first commit

This commit is contained in:
zzc
1970-01-01 08:27:52 +08:00
commit 3c80593c3d
135 changed files with 19822 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
// ScreenAdapter.ts
import { _decorator, Component, view, ResolutionPolicy } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('ScreenAdapter')
export class ScreenAdapter extends Component {
@property
designWidth: number = 1080; // 默认设计宽度
@property
designHeight: number = 1920; // 默认设计高度
onLoad() {
this.applyAdapter();
}
/**
* 应用屏幕适配
*/
applyAdapter() {
// const frameSize = view.getFrameSize();
// const aspect = frameSize.width / frameSize.height;
// const designAspect = this.designWidth / this.designHeight;
// if (aspect > designAspect) {
// // 屏幕更宽 → 固定高度,保证上下完整
// view.setDesignResolutionSize(this.designWidth, this.designHeight, ResolutionPolicy.FIXED_HEIGHT);
// console.log('[ScreenAdapter] Use FIXED_HEIGHT, aspect =', aspect.toFixed(2));
// } else {
// // 屏幕更窄 → 固定宽度,保证左右完整
// view.setDesignResolutionSize(this.designWidth, this.designHeight, ResolutionPolicy.FIXED_WIDTH);
// console.log('[ScreenAdapter] Use FIXED_WIDTH, aspect =', aspect.toFixed(2));
// }
}
}