Jump to content

How to get anchor offset?


Recommended Posts

Suppose I have a sprite with anchor x/y at .5. I want to figure out how many pixels that .5 moves the origin from the original at 0,0. I want to find the 'offset' so to speak. 


Is there a simply and easy way get this inside of phaser? I'm trying to avoid unnecessary calculations (like the below code).


function findAnchorOffset(sprite) {if(sprite.anchor.x == .5) {sprite.anchorOffsetX = sprite.width / 2;sprite.anchorOffsetY = sprite.height / 2;} else {sprite.anchorOffsetX = 0;sprite.anchorOffsetY = 0;}} 
Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...