Image scope

I have a class that extends container, which i have 2 images in.

I have 5 of these classes in my scene and they should operate independently of each other.

They all use the same set of images which I add to the main scene on object creation.

I’m having issues where modifying a property an image on one object, modifies that property across all objects.

Am I missing something? I am fairly new to the web stuff, having come from C# where members of an object don’t behave this way.

You should create a codpen showing the issue; it would be important to see how you are defining and instantiating the class. That being said, JS Classes are not like classes in class-based languages; it sounds like you are modifying a property of the prototype.

I have put my scene and the class i am using (removing some of the irrelevant parts) into a pastebin paste

https://pastebin.com/Hikac1Wy

I am working in typescript too if that helps

Turns out I am an idiot and didnt read documentation on things.

I was initializing my velocity to Phaser.Math.Vector2.ZERO, which i shouldnt have been doing as it mean all the objects used the same velocity reference. (the documentatioin for that specifically says its a static reference and should only be used for comparison.

What I thought was a weird scoping issue with javascript/typescript was merely a bad reference on my part. :upside_down_face: