Using phaser, how do I make the bricks I created appear on screen?

Hi all

I am following this tutorial: Collision detection - Game development | MDN

I copy pasted their code into my repl. In their game, bricks appear, but in my game, they don’t. Why is this? What must I change?
Their game: Gamedev Phaser Workshop - lesson 10 - JSFiddle - Code Playground
My game:

Thanks for your time


@lasjorg any thoughts on this? You solved my previous problem regarding getting a black canvas using phaser the other day, perhaps you know what may be wrong this time?

You need to declare the loop index variables in the two for loops inside initBricks.

Not sure why the original code is written that way, it’s never a good idea to have undeclared variables. If you look in the console you can see the error.

1 Like

Thanks again @lasjorg, you make it look easy :fist_right: :fist_left:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.