Animated spritesheet as the particle texture - ParticleEmitter

Hello! I’m facing some issues regarding the ParticleEmitter.

I’m currently able to create a particule emitter with a specific texture. However, I would like to change the texture frame of the particles based on a spritesheet animation.

I can use my spritesheet as the current texture for the particles but the particle texture is not animated according to my spritesheet animation. How can I achieve that? I can’t find any example for this specific issue.

Thanks!

Here’s a pseudo code:

 var config = {
      speed: { min: this.minSpeed * assetsDPR, max: this.maxSpeed * assetsDPR },
      lifespan: { min: this.minLifeSpan, max: this.maxLifeSpan },
      scale: { start: this.minScale * assetsDPR, end: this.maxScale * assetsDPR },
      blendMode: this.blendMode,
      duration: this.duration,
      quantity: this.quantity
    }

var tempTexture = this.scene.textures.get(this.texture)
var isSpriteSheet = tempTexture && tempTexture.hasOwnProperty('frameTotal')

if (isSpriteSheet) {
  // TODO : animate the particles according to the spriteSheet texture

  // Test
  // config['frames] = ...
}

// Create ParticleEmitter
this.itemObject = this.scene.add.particles(this.x, this.y, this.texture, config)
const emitter = this.add.particles(400, 300, 'gems', {
    anim: 'prism'
    // etc.
});
1 Like

Wow! It’s a good thing that I’m using the 3.6v!

Thanks!

1 Like