大侠
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

102 lines
3.3 KiB

import { _decorator, assetManager, Camera, Canvas, Collider2D, Component, debug, director, DynamicAtlasManager, game, instantiate, JsonAsset, Label, macro, Node, PhysicsSystem2D, Prefab, profiler, ProgressBar, screen, sys, TextAsset, view } from 'cc';
import {MainConfig} from './_MainConfig';
import { EDITOR, MINIGAME, PREVIEW } from 'cc/env';
import ScriptLaunch from '../Scripts/ScriptLaunch';
const { ccclass, property } = _decorator;
// DynamicAtlasManager.instance.maxAtlasCount = 8;
// DynamicAtlasManager.instance.maxFrameSize = 512;
DynamicAtlasManager.instance.enabled = false;
macro.CLEANUP_IMAGE_CACHE = true;
@ccclass('Launch')
export class Launch extends Component {
@property(Node)
lab_GameName: Node = null;
@property(Node)
lab_v: Node = null;
@property(Node)
lab_Copyright: Node = null;
@property(Node)
lab_HealthAdvice: Node = null;
@property(Label)
lab_LOGO: Label = null
@property(Node)
loading: Node = null;
@property(ProgressBar)
ProgressBar: ProgressBar = null;
@property(Canvas)
mCanvas: Canvas = null;
@property(Camera)
mCamera: Camera = null;
@property(Prefab)
mPrefab:Prefab = null;
@property([Node])
mLogo: Node[] = [];
@property(TextAsset)
mText:TextAsset;
@property(Node)
btn_restart: Node = null;
protected onLoad(): void {
MainConfig.isMiniGame = MINIGAME;
game.frameRate = MainConfig.GameFarme;
console.log("os ", sys.os)
console.log("Platform ", sys.platform)
console.log("isBrowser ", sys.isBrowser)
console.log("isMobile ", sys.isMobile)
console.log("isNative ", sys.isNative)
/**初始化游戏引擎数据 */
this.initGameData();
}
start() {
this.lab_GameName.getComponent(Label).string = MainConfig.ZHName;
this.lab_v.getComponent(Label).string = `游戏版本:${MainConfig.DisplayVersions}`;
let tNode = instantiate(this.mPrefab);
tNode.getComponent(ScriptLaunch).setClassPoxy(this);
this.node.addChild(tNode);
}
private initGameData() {
/** FPS显示 */
this.setdebugDisplayStats(PREVIEW && false);
}
/**
* 设置debug信息描边
* @param isShow
*/
setdebugDisplayStats(isShow: boolean) {
if (MainConfig.isMiniGame) { return; }
profiler.showStats();
//@ts-ignore
let ctx = profiler._ctx;
ctx.font = `23px Arial`;
ctx.fillStyle = 'rgba(255, 255, 255, 0.8)';
ctx.strokeStyle = 'rgba(0, 0, 0, 0.8)';
ctx.lineWidth = 3;
let originFillText = CanvasRenderingContext2D.prototype.fillText;
ctx.fillText = (text, x, y, maxWidth) => {
ctx.strokeText(text, x, y);
originFillText.call(ctx, text, x, y);
};
//清空canvas, 重新绘制贴图
ctx.clearRect(0, 0, 280, 280);
//@ts-ignore
profiler._statsDone = false;
profiler.generateStats();
//删除并重建节点. 如果改了字体尺寸, 则需要重建节点
//@ts-ignore
profiler._rootNode.destroy();
//@ts-ignore
profiler._rootNode = null;
profiler.generateNode();
if (profiler["_showFPS"] != isShow) {
!isShow && profiler.hideStats();
}
}
}