How can I get the top left corner position of the screen, if the image is anchored on the top right corner? Basically, I want to tween an image element from the top right corner to the top left corner. On this case the 0,0,0 of the image is at the top right corner, how can I get the position it would be on the top left corner?
I think you can solve this with simple math:
First you need to get the actual screen width, and substract the half extents of your element + whatever margin you are using
That result is the total distance the element has to travel.
Another way of doing this is puting a disabled element (so you don’t see it) in the spot where you want your element to go to, make sure to anchor it to the top-left of the screen. Then you can get that element’s position and set it to the target of the tween.
Does it make sense?
Interestingly, it’s actually this.app.graphicsDevice.width/2, not this.app.graphicsDevice.width that works. I still need to subtract the amount of pixels the image has for the width. How can I do that?
Ah, maybe you’ve got this.app.graphicsDevice.scale set to 2.
Height and width are propertìes of image elements. You can get those doing.
let elementWidth = entity.element.width let elementHeight = entity.element.height
EDIT: Sorry, not the “scale” , as there’s no property called scale in the graphicsDevice object. I meant maxPixelRatio, wich reprensents the ratio between the screencomponent size and the actual pixels the app has to draw. Although I am not sure this is 100% technically accurate definiton