jorge luis
jorge luis

Reputation: 31

How to run a JavaScript code before a phaser script?

I want to run my own script (On JavaScript, and Apache Thrift), but it MUST run before a phaser script, but phaser run first! I want to do this, because I have some variables in my first script that I need in phaser, and when phaser run first, that variables doesn't exist yet! until the other script run.

That variable is the length of the objects that I will have in phaser.

var elements=numbers;
var comunity=[elements];

The variable "numbers" is defined in the first script, but phaser run first and when phaser try to load "numbers" numbers is undefined!, but when the other script run "numbers" value is 50. I have the 1-st script before the phaser script, I need some help please.

Upvotes: 3

Views: 107

Answers (1)

TimoStaudinger
TimoStaudinger

Reputation: 42460

As long as the scripts are not loaded dynamically or defered, they are executed in the order they are encountered in the document. Since JavaScript is executed in a single thread, no scripts will be executed in parallel either.

For this reason, it should be sufficient to embed/load your own script before the phaser script.

Upvotes: 1

Related Questions