Dom element (img) position/origins changed

Hi

I load image from facebook dinamically, so i use dom to show it.

The problem if i change or restart the scene, the img dom position/origin are changed.

img 1 (normal position)

ws1

img 2 (wrong position)

dhyfg

img 3 (wrong position)

ws2

It’s look like their origin are set to (0,0.5), instead of (0,0) default. or switched it’s vertical origin to center.

if dom img are loaded quickly (look like img are cached) this position changes are never happen.
but if there are a delay to fetching a image (facebook), this problem are appear. except for first dom, the second dom request are got different position.

how to fix this ? or how to cache it’s image only for this session.

let img = document.createElement('img');
  img.src = photo_url;
  img.width = 69;
  let photo_dom = this.add.dom(275, 170, img);

Hi,

I’m not sure if this will fix it as I haven’t played around much with the dom game object but you could set the origin when creating the dom game object. for example.

let photo_dom = this.add.dom(275, 170, img).setOrigin(0, 0);

Hopefully that helps :slight_smile:

It’s working, i think setOrigin are not working with dom object, but i was wrong.

Thanks