Scaling Textures from the Center RRS feed

  • Question

  • Hello,

    It has been a while since I last posted here but I am working on a new project. I am making a mini map for my program and I am including a (zoom in/zoom out) function.

    I can get the map to zoom in and out from the top left corner, however, how can I get it to zoom in from the center? (the player is always positioned in the center)

    Here is a sample of my code:

    spriteBatch.Draw(worldMap.texture, new Rectangle((int)miniMapPos.X, (int)miniMapPos.Y, (int)miniMapSize.X, (int) miniMapSize.Y), new Rectangle((int)moveMiniMap.X, (int)moveMiniMap.Y, (int)scaleMiniMap.X, (int)scaleMiniMap.Y), Color.DarkOrange);

    spriteBatch.Draw(player.texture, new Rectangle((int) miniPlayerPos.X, (int) miniPlayerPos.Y, (int) miniPlayerSize.X, (int) miniPlayerSize.Y), Color.White);


    - Chris
    • Moved by Michael Sun [MSFT]Microsoft employee Wednesday, October 15, 2008 5:53 AM Off Topic for Visual C# General [loc] (Moved from Visual C# General to Off-Topic Posts (Do Not Post Here))
    Friday, October 10, 2008 6:01 PM

All replies



            Since SpriteBatch Class is in Microsoft.Xna.Framework assembly, I think your thread is off topic for Visual C# General.   You could find more help at http://forums.xna.com



    Best Regards,

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/csharpide/thread/8e9ed0d7-11ff-402a-8489-9b5f05eeb706 http://forums.msdn.microsoft.com/en-US/vssetup/thread/60424309-bd78-4ca2-b618-03c4a16123b6
    Wednesday, October 15, 2008 5:53 AM