ForgeableSum Posted March 6, 2015 Share Posted March 6, 2015 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 More sharing options...
MikeT Posted March 6, 2015 Share Posted March 6, 2015 sprite.anchorOffsetX = sprite.width * sprite.anchor.x;sprite.anchorOffsetY = sprite.height * sprite.anchor.y;Maybe this? Link to comment Share on other sites More sharing options...
ForgeableSum Posted March 6, 2015 Author Share Posted March 6, 2015 sprite.anchorOffsetX = sprite.width * sprite.anchor.x;sprite.anchorOffsetY = sprite.height * sprite.anchor.y;Maybe this? That's a lot more concise than what I had. Thanks. Too bad there isn't a direct reference to the stored value. Link to comment Share on other sites More sharing options...
Recommended Posts