[SOLVED] App.on listener firing at start of game?

I’ve been having issues with a scene loading script in my game this morning, and broke the issue down to this: PlayCanvas | HTML5 Game Engine

Basically my issue is that the scene loading event(in my other code) is being triggered instantly as soon as the title screen starts up.

I then made the above test from scratch, using a fresh scene and a newly created script file. It’s an empty scene, with a single script attached to the Root object. When I run that, my debug console has a single “OOPS IT HAPPENED ANYWAY”, despite NOTHING in the application ever calling that function, or sending the listen message of “THIS_SHOULD_NEVER_HAPPEN”.

What am I missing or doing wrong here? How can I stop/prevent the loading event from firing until the user actually triggers the event? (The loading code is in my real game scene, this one is just an example I made to show my problem, but the code setup is exactly the same.)

You’re calling the function…

app.on("THIS_SHOULD_NEVER_HAPPEN",this.should_not_happen(),this);

Should be:

app.on("THIS_SHOULD_NEVER_HAPPEN",this.should_not_happen,this);

No brackets after this.should_not_happen

1 Like

So silly of me. Thanks! :smile: