Problem creating group from an atlas

Hi all,
I am trying to create a group from several frames of an atlas (json), but none of the created elements use the frames that I indicate, they only use the first frame of the atlas.
I have been able to add images, sprites and animations with the atlas.
This is my code:

this.meteors = this.physics.add.group();
    this.meteors.createMultiple({
      classType: Meteor,
      key: 'atl_asteroids',
      frame: ['009_asteroid1','010_asteroid2', '011_asteroid3','012_asteroid4'],
      frameQuantity: 10,
      //randomFrame: true,
      max: t.conf.meteors_qty*4
    });

This is a reduced version of the atlas:

{
  "frames": {
    "000_Ship2": {
      "frame": { "x": 0, "y": 0, "w": 62, "h": 55 },
      "rotated": false,
      "trimmed": false,
      "spriteSourceSize": { "x": 0, "y": 0, "w": 62, "h": 55 },
      "sourceSize": { "w": 62, "h": 55 }
    },
    "001_Ship1": {
      "frame": { "x": 121, "y": 0, "w": 62, "h": 55 },
      "rotated": false,
      "trimmed": false,
      "spriteSourceSize": { "x": 0, "y": 0, "w": 62, "h": 55 },
      "sourceSize": { "w": 62, "h": 55 }
    }
  },
  "meta": {
    "image": "spritesheet.png",
    "size": { "w": 1190, "h": 604 },
    "scale": 1
  }
}

What am I missing?

Thanks in advance.

In the docs frame takes an integer or string and not an array of strings.

Maybe something like this:

this.meteors = this.physics.add.group()
const frames = ['009_asteroid1', '010_asteroid2', '011_asteroid3', '012_asteroid4']

for (let i = 0; i < t.conf.meteors_qty * 4; i++) {
  const pos = { x: 100 * i, y: 100 }
  this.meteors.create(pos.x, pos.y, 'atl_asteroids', Phaser.Math.RND.pick(frames))
}

You can pass an array for frame (docs are incorrect on that, sorry).

Make sure the frame names (009_asteroid1 etc.) are in the atlas.

Make sure your Meteor class accepts and passes the frame argument in the right place.

1 Like

Problem resolved :+1:. Thanks everyone for your help.

@samme you’re right, that was the problem. Thank you!! .