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
wrong texture
Console error:
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,
});