How would I create collisions between these and the bullets

Once again thank you. If you are willing I have a few more questions that I am struggling to get working(once again I understand if your don’t want to at this point, I am not sure if I need to start another topic or note).

I have Some code that swawns in walls at random what works by creating a class that extends the sprite:

class Wall1 extends Phaser.Physics.Arcade.Sprite{
       constructor(config){
             super(config.scene, config.x, config.y, "wall1" );
            let aa = Phaser.Math.Between(0, 360);
            this.rotation = aa;
            config.scene.add.existing(this);
      }
}

These are are spawned by:

for(var i = 0; i < 5; i++){
        let xx = Phaser.Math.Between(25, game.config.width - 30);
        let yy = Phaser.Math.Between(25, game.config.height - 50);
        let wall1 = new Wall1({scene:this, x:xx, y:yy, });
}

How would I create collisions between these and the bullets While I am at it these walls and the player?

Sorry I this is to much.

Edit: Also How do I make the code inlined, like when you edited my orginal post? I have looked on the site but can’t find how to.

For code blocks use the Preformatted text button in the editor with the cursor on an empty line.

You can store the walls in an array or a physics group, then add a collider for that. Here is an array:

var walls = [];

for (var i = 0; i < 5; i++) {
  let xx = Phaser.Math.Between(25, game.config.width - 30);
  let yy = Phaser.Math.Between(25, game.config.height - 50);
  walls[i] = new Wall1({ scene: this, x: xx, y: yy });
}

this.physics.add.collider(bullets, walls);
this.physics.add.collider(player, walls);

Thanks for responding and awnsering the other unrealted questions.

I tried the array method as you mentioned however that did not work, both the player and bullets just pass through the walls. The code is the same just with what you added there. I am not sure what I did wrong there. Out of interesting what would the group example look like?

Edit: Sorry I am an idiot and forgot to enable physics on wall objects. I can now collide between the player and walls. The wall textures have disppaeared however.

So to genertate the walls I am using:
In the create function

var walls = [];
        
        for(var i = 0; i < 5; i++){
            let xx = Phaser.Math.Between(25, game.config.width - 30);
            let yy = Phaser.Math.Between(25, game.config.height - 50);
            walls[i] = new Wall1({scene:this, x:xx, y:yy, });
            walls[i].setImmovable();
        }

unreated code

        this.physics.add.collider(this.projectiles, walls,);
        this.physics.add.collider(this.player, walls);

The class:

class Wall1 extends Phaser.Physics.Arcade.Sprite{
    constructor(config){
        super(config.scene, config.x, config.y, "wall1" );
        let aa = Phaser.Math.Between(0, 360);
        console.log("Wall Check 1")
        this.rotation = aa;
        
        config.scene.physics.add.existing(this);
    }
}

However doing this has cause the texture to disappear and the roatation to stop working.

You need to add to the scene as well:

config.scene.add.existing(this);

Also since aa is in degrees you probably want

this.angle = aa;

Bear in mind that Arcade Physics bodies don’t rotate though.

Isn’t that what this:

config.scene.physics.add.existing(this);

Is doing?

Yeah physics colliders don’t rotate in arcade. I learn that after asking the post but though I had edited it enough by that point.

Edit:
As you may be able to tell, I am not very good at this. Having added that it is working the sprites are functioning. Thanks for the help you have given me. I now just need to figure out enemies.

No, physics.add.existing() creates a physics body and adds to the physics simulation and add.existing() adds to the scene display list.