generateTexture not showing up and weird texture substitution behavior

I want the yellow circle around my mouse pointer. The generated texture isn’t showing up (first pic). If I use an external asset with this.load it works, but I would like to understand what I’m doing wrong here. Also, uncommenting the this.enemy line puts a squished enemy texture around the mouse pointer (2nd pic). Is using another texture when there’s an issue with the requested one Phaser’s default behavior? The console error is the 3rd pic. I thought it had something to do with destroying the graphics object, but it’s still there with graphics.destroy() commented.

Any help would be appreciated. Thanks!

no texture
reticle
wrong texture
image
Console error:
image

export default class ReticleScene extends Phaser.Scene {
  reticle;

  /* for weird texture behavior */
  enemy;
  preload() {
       this.load.spritesheet('enemy', 'assets/floating_thing.png',
       { frameWidth: 45, frameHeight: 72 }
     );
  }

  create() {
      let graphics = this.make.graphics({x:0, y:0, add: false}); // pics generated with add: true
      graphics.lineStyle(2, 0xffff00, 1.0);
      graphics.strokeCircle(24, 24, 24);
      graphics.generateTexture('reticle', 48, 48);
      // graphics.destroy();

      this.reticle = this.physics.add.image(250, 250, 'reticle');

      this.input.on('pointermove', function (pointer) {
          this.reticle.x = pointer.x;
          this.reticle.y = pointer.y;
      }, this);

  // uncommenting this will use the enemy texture for this.reticle
  // this.enemy = this.physics.add.sprite(400, 300, 'enemy');
  }
}

const game = new Phaser.Game({
  type: Phaser.AUTO,
  width: 800,
  height: 600,
  physics: {
    default: 'arcade',
    arcade: {
      gravity: { y: 0 },
      debug: true
    }
  },
  scene: ReticleScene,
});

I do not know why it id behaving wrong. I have tested it in codepen and it works like expected.

Have a look

1 Like

Thank you! Turns out I had to update Phaser.
Your obviously working example was demonstrating the same behavior for me locally. I checked the Phaser version:
npm view phaser version
3.16.2

But, it was a lie. Phaser in node_modules was 3.13.
npm update phaser and my original code is working.