Skip to content

Commit

Permalink
Start games without loading screen if assets are ready before half th…
Browse files Browse the repository at this point in the history
…e fade-in
  • Loading branch information
D8H committed Dec 6, 2023
1 parent 4f04190 commit 4107a66
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion GDJS/Runtime/pixi-renderers/loadingscreen-pixi-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ namespace gdjs {
_lastFrameTimeInMs: float = 0;
_progressPercent: float = 0;

private _isWatermarkEnabled: boolean;

constructor(
runtimeGamePixiRenderer: gdjs.RuntimeGamePixiRenderer,
imageManager: gdjs.PixiImageManager,
loadingScreenData: LoadingScreenData,
isWatermarkEnabled: boolean,
isFirstScene: boolean
) {
this._loadingScreenData = loadingScreenData;
this._isWatermarkEnabled = isWatermarkEnabled;
this._isFirstLayout = isFirstScene;
this._loadingScreenContainer = new PIXI.Container();
this._pixiRenderer = runtimeGamePixiRenderer.getPIXIRenderer();
Expand Down Expand Up @@ -272,8 +276,22 @@ namespace gdjs {
totalElapsedTime;
this.setPercent(100);

const fadeInDuration = Math.min(
this._loadingScreenData.showGDevelopSplash
? this._loadingScreenData.logoAndProgressLogoFadeInDelay +
this._loadingScreenData.logoAndProgressFadeInDuration
: Number.POSITIVE_INFINITY,
this._loadingScreenData.backgroundImageResourceName ||
this._loadingScreenData.backgroundColor
? this._loadingScreenData.backgroundFadeInDuration
: Number.POSITIVE_INFINITY
);

// Ensure we have shown the loading screen for at least minDuration.
if (remainingTime <= 0) {
if (
remainingTime <= 0 ||
(this._isWatermarkEnabled && totalElapsedTime < fadeInDuration / 2)
) {
this._state = LoadingScreenState.FINISHED;
return Promise.resolve();
}
Expand Down

0 comments on commit 4107a66

Please sign in to comment.