Arcanorum Posted September 24, 2016 Share Posted September 24, 2016 I have a sprite with an anchor of 0.5, 0.5, so the middle of the sprite. How would I add a circle body to the sprite with the center of the circle on the anchor of the sprite, so that if I scaled the sprite, the circle would scale from the middle of the sprite and not from the top left? Seems simple but setCircle (and setSize) seems to be messed up as I've been trying to get them to work all day... - Circle body size doesn't seem to respect the scale of the parent sprite or its anchor. Link to comment Share on other sites More sharing options...
samme Posted September 24, 2016 Share Posted September 24, 2016 (edited) Hi Arcanorum, I haven't used circular bodies but, AFAIK The body is always centered on the sprite, regardless of the sprite's anchor, unless you change the body offset Always resize a circular body w/ setCircle, never setSize (which removes the circle) The body offset refers to the sprite texture, so it's also scaled when the texture (sprite) is scaled Edited September 24, 2016 by samme wrong Link to comment Share on other sites More sharing options...
Arcanorum Posted September 24, 2016 Author Share Posted September 24, 2016 Link to comment Share on other sites More sharing options...
samme Posted September 24, 2016 Share Posted September 24, 2016 OK I was wrong about the centered part try var radius = sprite.width / 2; sprite.body.setCircle( radius, (-radius + 0.5 * sprite.width / sprite.scale.x), (-radius + 0.5 * sprite.height / sprite.scale.y) ); http://codepen.io/anon/pen/ORpvjd?editors=0010 Kraken 1 Link to comment Share on other sites More sharing options...
Recommended Posts