troubleshooting Question

My Javascript Phaser Udemy Game example needs some suggestions to fire-up

Avatar of James Hancock
James HancockFlag for United States of America asked on
Game ProgrammingJavaScript
5 Comments1 Solution165 ViewsLast Modified:
In a Udemy video lecture on 'building games with phaser', the instructor is working w the following 'ColorZap' project code zip below..
He is using brackets for an IDE, so so am I:

My XAMPP serves the files correctly, no problem, in Safari.

So, he has a main.js that tries to start the game object.

main.js :
var game;
//var score;
//var soundOn = true;

window.onload = function () {
    if (screen.width > 1500) {
        //desktop laptop
        game = new Phaser.Game(480, 640, Phaser.AUTO, "ph_game");

    } else {
        //mobile device
        game = new Phaser.Game(window.innerWidth, window.innerHeight, Phaser.AUTO, "ph_game");
    //add a state or screen to the game
    game.state.add("StateMain", StateMain);
    game.state.add("StateTitle", StateTitle);


But, the Problems console claims:

"Missing 'use strict' statement    if (screen.width > 1500) {

but most notably: Phaser was used before it was defined. . game = new Phaser.Game(480, 640, Phaser.AUTO, "ph_game");

which puzzles me, because where are the lines of code in his example or way this can work? I wrote the code from the Udemy vid. I can't imagine I left something off.

These project files are attached also. What could I not have done? Where do I define Phaser for it? Is there a  #include equivalent?
A black rectangle appears in the browser to test the code, so I know the size of the program area is being registered properly.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros