Skip to content

Commit

Permalink
WeChat mini game platform remove splash-screen implementation (#17518)
Browse files Browse the repository at this point in the history
* WeChat mini game platform remove splash-screen implementation

* Add a comment

---------

Co-authored-by: qiuguohua <[email protected]>
  • Loading branch information
qiuguohua and qiuguohua authored Aug 12, 2024
1 parent 5114cb1 commit 71faf05
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion cocos/game/splash-screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
THE SOFTWARE.
*/

import { EDITOR } from 'internal:constants';
import { EDITOR, WECHAT } from 'internal:constants';
import { Material } from '../asset/assets/material';
import { clamp01, Mat4, Vec2, Settings, settings, sys, cclegacy, easing, preTransforms } from '../core';
import {
Expand Down Expand Up @@ -114,6 +114,9 @@ export class SplashScreen {
private scaleSize = 1;

public get isFinished (): boolean {
if (WECHAT) {
return true;
}
return this._curTime >= this.settings.totalTime;
}

Expand All @@ -126,6 +129,10 @@ export class SplashScreen {
}

public init (): Promise<void[]> {
// The WeChat mini-game's splash screen is using the implementation in first-screen.
if (WECHAT) {
return Promise.resolve([]);
}
let policy: number = ResolutionPolicy.SHOW_ALL;
if (!EDITOR) {
const designResolution = settings.querySettings(Settings.Category.SCREEN, 'designResolution');
Expand Down Expand Up @@ -190,6 +197,9 @@ export class SplashScreen {
}

private preInit (): void {
if (WECHAT) {
return;
}
const clearColor = this.settings.background?.color;
this.clearColors = clearColor ? [new Color(clearColor.x, clearColor.y, clearColor.z, clearColor.w)] : [new Color(0, 0, 0, 1)];
const { device, swapchain } = this;
Expand Down Expand Up @@ -246,6 +256,9 @@ export class SplashScreen {
}

private initLayout (): void {
if (WECHAT) {
return;
}
if (this.isMobile) {
this.bgWidth = 812;
this.bgHeight = 375;
Expand Down Expand Up @@ -275,6 +288,9 @@ export class SplashScreen {
}

private initScale (): void {
if (WECHAT) {
return;
}
const dw = this.swapchain.width; const dh = this.swapchain.height;
let desiredWidth = this.isMobile ? 375 : 1080;
let desiredHeight = this.isMobile ? 812 : 1920;
Expand All @@ -291,6 +307,9 @@ export class SplashScreen {
}

public update (deltaTime: number): void {
if (WECHAT) {
return;
}
const settings = this.settings;
const { device, swapchain } = this;
Mat4.ortho(
Expand Down Expand Up @@ -382,6 +401,9 @@ export class SplashScreen {
}

private initBG (): void {
if (WECHAT) {
return;
}
const device = this.device;

this.bgMat = new Material();
Expand Down Expand Up @@ -416,6 +438,9 @@ export class SplashScreen {
}

private initLogo (): void {
if (WECHAT) {
return;
}
const device = this.device;

this.logoMat = new Material();
Expand Down Expand Up @@ -459,6 +484,9 @@ export class SplashScreen {
}

private initWaterMark (): void {
if (WECHAT) {
return;
}
// create texture from image
const watermarkImg = ccwindow.document.createElement('canvas');
watermarkImg.height = this.textHeight * this.scaleSize;
Expand Down Expand Up @@ -494,6 +522,9 @@ export class SplashScreen {
}

private frame (): void {
if (WECHAT) {
return;
}
const { device, swapchain } = this;

if (!sys.isXR || xr.entry.isRenderAllowable()) {
Expand Down Expand Up @@ -620,6 +651,9 @@ export class SplashScreen {
}

private destroy (): void {
if (WECHAT) {
return;
}
this.device = null!;
this.swapchain = null!;
this.clearColors = null!;
Expand Down

0 comments on commit 71faf05

Please sign in to comment.