Javascript 如何在Phaser3中引用游戏对象

Javascript 如何在Phaser3中引用游戏对象,javascript,phaser-framework,Javascript,Phaser Framework,我觉得这应该是一个简单的答案,但我对Phaser还不熟悉,不擅长javascript,而且还很挣扎 我如何引用游戏对象metrus(使用metrus类创建)来在创建后处理它?我需要单独引用每个对象,以便专门使用其ID来处理它 我的游戏场景: var metrus = []; class Metrus extends Phaser.Physics.Arcade.Image { constructor(scene, x, y, motion, direction, distance, id) {

我觉得这应该是一个简单的答案,但我对Phaser还不熟悉,不擅长javascript,而且还很挣扎

我如何引用游戏对象metrus(使用metrus类创建)来在创建后处理它?我需要单独引用每个对象,以便专门使用其ID来处理它

我的游戏场景:

var metrus = [];

class Metrus extends Phaser.Physics.Arcade.Image {

constructor(scene, x, y, motion, direction, distance, id) {
super(scene, x, y, 'metrustotalsprite', direction.offset);

this.id = id;
this.name = id;
this.startX = x;
this.startY = y;
this.distance = distance;
this.scene = scene;

this.setDataEnabled();
this.data.set('id', id);

var unitSprite = this.scene.matter.add.gameObject(this, { shape: 'circle', width: 30, height: 30, circleRadius: 15}).setName(id);   

unitSprite.displayWidth = 30;
unitSprite.displayHeight = 30;
unitSprite.scale = 0.4;

}

}

class GameScene extends Phaser.Scene {

constructor() {
super('GameScene')  
}

preload () {
//ASSET PRELOAD HERE, ETC
}

create () {
 //I CREATE MY WORLD TILES HERE AND OTHER SIMPLE FUNCTIONS
//THEN I GO THROUGH AN AJAX CALL TO GET DATA FOR THIS:
thisUnit = metruss.push(this.add.existing(new Metrus(this, centerX + txOffset, centerY + tyOffset, 
unitAction, unitDirection, 150, unitId)));
                                
                                
 }

}