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));
// }
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "043cfab9-7936-40a6-ab63-145e9193c71a",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,13 @@
import { resources, SpriteFrame } from "cc";
export const loadSpriteFrames = (dir: string): Promise<SpriteFrame[]> => {
return new Promise((resolve, reject) => {
resources.loadDir(dir, SpriteFrame, (err, frames) => {
if (err) {
reject(err);
return;
}
resolve(frames);
});
});
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "a2baa6eb-8db8-4998-9719-ae146445a3e2",
"files": [],
"subMetas": {},
"userData": {}
}