XNA Sprite Scaling: looking for uniform expansion from the center of the sprite
When I scale my sprite, it's stretches out to the lower right, when the desired effect is for it to stay put and 'grow' in concentric circles.
I fiddled around with the origin, but it seems to only affect rotation. I've also thought about using the bounding rectangle to scale it, but I'm looking for a best practice so as not to get into a bad habit right out of the gate.
Here's the code where I make the call. The only arg that changes is Scale:
SpriteBatch.Draw(Texture, // Texture
Position, // Position
开发者_C百科 null, // Source Rectangle
Color, // Color
0f, // Rotation
Vector2.Zero, // Origin
Scale, // Current Scale
SpriteEffects.None, // Mirroring options
Depth); // z-depth
And here's a screenshot of the orange rings expanding without staying 'stacked':
Thanks for your time.
Here's a detail of the fixed version if it helps anyone:
The sprite origin passed to SpriteBatch.Draw
is specified in sprite coordinates (pixels) and is used as the origin for scaling, as well rotation and position.
Scale is specified as a multiplier (so Vector2.One
is at "normal" size).
精彩评论