Https://www.codecademy.com/courses/learn-phaser/projects/learn-phaser-codey-jump

https://www.codecademy.com/courses/learn-phaser/projects/learn-phaser-codey-jump

I’m not sure where to file this topic, so please let me know if I should be posting elsewhere or if I need to include more appropriate tags.

I’m was having a bit of trouble with the “Codey Jump” project within the Phaser.js skill path and thought I might start a conversation in case future learners find themselves in a similar situation.

One noticeable difference in this project is the definition of global variables at the start of game.js, which requires the coder to be more attentive than in previous lessons; in earlier exercises, we often defined a variable and assigned behaviors to this variable within the create() function of the class to which the variable belongs (or its parent class). I found myself making more simple mistakes when working with variables that were defined out of sight.

Second (and relatedly), my code was stalling entirely when creating the emitter in step 10. After watching the walkthrough a few times, I realized that I had made an earlier error in step 8. This error was defining particles at the top of create(), instead of after the definition and modification of the graphics variable. Here’s how the beginning of the create() function should appear:

create() {

    const graphics = this.add.graphics();
    graphics.fillGradientStyle(0xdadaff, 0x6cfafa, 0xfccaff, 0xdadaff, 1);
    graphics.fillRect(0, 0, gameOptions.width, gameOptions.height);

    particles = this.add.particles('stripe');
\\ code continues
}

One question I had was why we wouldn’t define the particles globally at the top along with the other variables. I’m still stumbling through Phaser.js, so perhaps the answers to my questions will be addressed in future units. If so, I’ll return to edit this post.

EDIT: Welp, I had not clicked “Next” from the “Codey Jumps” project before posting…turns out that this is the final project. Despite the confetti, I’m still a bit lost and welcome any input on Phaser.js that others might have!