Hi,
i have the following code in which I define a class:
runtime.globalVars.class_Axt = class axt {
constructor() {
this.name = "Axe"
this.MapObject = 0
this.ziel_person = 0
}
ausruesten(ziel_person) {
this.ziel_person = ziel_person;
this.ziel_person.onHand = this;
this.MapObject = runtime.objects.Axt.createInstance("Items", this.ziel_person.MapObject.x, this.ziel_person.MapObject.y, false);
this.MapObject.addEventListener("tick", this.mapObject_moveto);
}
mapObject_moveto() {
this.MapObject.x = this.ziel_person.MapObject.x;
this.MapObject.y = this.ziel_person.MapObject.y;
}
}
Then I create objects and use the method ausruesten:
runtime.globalVars.a = new runtime.globalVars.class_Axt();
runtime.globalVars.max = new runtime.globalVars.class_Person(runtime.objects.MainPlayer.getFirstInstance());
runtime.globalVars.a.ausruesten(runtime.globalVars.max);
Everything works as intended except the addEventListener in ausruesten method. Im not sure whats wrong. I tested it a lot but the event is never triggering. Can someone help me and explain how it could work and why?