Hi, there! First time posting in the new forum.
I’m going with an OOP approach with Phaser 3 but I can’t assign texture to children elements in a group. The debug: true draws just an outline. Here’s my code:
src/Sprites/EnemyGroup.js:
import 'phaser';
export default class EnemyGroup extends Phaser.Physics.Arcade.Group {
constructor(world, scene, config) {
super(world, scene, config);
}
}
In the src/Scenes/GameScene.js:
import 'phaser';
import EnemyGroup from '../Sprites/EnemyGroup';
export default class GameScene extends Phaser.Scene {
constructor () {
super('Game');
}
// assets is at the same level as src
preload () {
this.load.image('enemy', 'assets/enemy.png');
}
create () {
var config = { key: 'enemy', frameQuantity: 10, visible: false, active: false, max: 10, setXY: {x: this.width + 30, y: this.height - 65} };
this.enemies = new EnemyGroup(this.physics.world, this, config);
}
.... // other code
}
What am I missing? My guess is that something goes wrong with passing the key in the config to the new EnemyGroup(). The issue arises when I try to use EnemyGroup as a separate file. If I write my code directly in the GameScene file, it works. Like so:
this.enemies = this.physics.add.group({ key: 'enemy', frameQuantity: 10, visible: false, active: false, max: 10, setXY: {x: this.width + 30, y: this.height - 65} });