How can I start the app manually in the loading screen script?

It seems that the app starts automatically with app.on('start', hideSplash);. The problem is that my loading screen has a start button, and the app is only supposed to start after the user taps on it. Is it possible? If not, is it possible to send an event from the loading screen to the app, to only do something after this event is received? Something like “realStart” event, that fires after the user taps on the start button.

Hi @Marks

Here is what I do. I create a minimal startup scene and a minimal createLoadingScreen function where I add my app specific startup code eg I fire my own “started” event, and load the actual first scene.

https://playcanvas.com/editor/code/971850?tabs=98558338

https://playcanvas.com/project/971850/overview/appstartuptest

2 Likes

Thanks Kulodo133. I’m reading the _startup.js script, and I can’t find where you defined the pleaseRunFromStartupScene function.

Hi @Marks,

It is intentionally not defined so the app crashes when the app is not started from the _startup scene. It was just to remind myself to always start the app from the _startup scene.

1 Like

The app-started.js doesn’t seem to be attached to any entity. It doesn’t have the usual pc.createScript code. Is this a self contained script that executes by itself? It runs just by existing in the folder?

EDIT

yep that’s case. Cool.