Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7928025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:37:41+00:00 2026-06-03T19:37:41+00:00

I have this code that is supposed to draw two volume icons to the

  • 0

I have this code that is supposed to draw two volume icons to the window, but it is not working. Here is the relevant code:

    Texture2D vol_max;
    Vector2 vol_max_vect;
    Texture2D vol_min;
    Vector2 vol_min_vect;
    ...
    protected override void LoadContent()
    {
        // Create a new SpriteBatch, which can be used to draw textures.
        spriteBatch = new SpriteBatch(GraphicsDevice);

        vol_max = Content.Load<Texture2D>("vol_max@16");
        vol_min = Content.Load<Texture2D>("vol_min@16");
    }
    protected override void Update(GameTime gameTime)
    {
        thisKeyboard = Keyboard.GetState(PlayerIndex.One);

        if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
            thisKeyboard.IsKeyDown(Keys.Escape))
        {
            this.Exit();
        }

        // Update window vectors
        vol_max_vect = new Vector2(
            (float)(Window.ClientBounds.Right - 20),
            (float)(Window.ClientBounds.Bottom - 20));
        vol_min_vect = new Vector2(
            (float)(Window.ClientBounds.Right - 140),
            (float)(Window.ClientBounds.Bottom - 20));

        prevKeyboard = thisKeyboard;

        base.Update(gameTime);
    }

    protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.CornflowerBlue);

        spriteBatch.Begin();
        spriteBatch.Draw(
            vol_max,
            vol_max_vect,
            Color.White);
        spriteBatch.Draw(
            vol_min,
            vol_min_vect,
            Color.White);
        spriteBatch.End();

        base.Draw(gameTime);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T19:37:43+00:00Added an answer on June 3, 2026 at 7:37 pm

    The issue is that the ClientBounds.Right/Bottom is in Windows screen coordinates (where [0,0] is the top left of your screen, and the bottom right is your resolution, eg. [1024, 768]).

    What you really want is to draw them at the bottom right of your own window. XNA’s SpriteBatch draws in viewport coordinates, where [0, 0] is the top left of your viewport, and the bottom right is your application’s resolution eg. [800, 480]. To get that width, you can simply use Window.ClientBounds.Width instead of Window.ClientBounds.Right, and Window.ClientBounds.Height instead of Window.ClientBounds.Bottom.

    Hopefully that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code that works in a unit test but doesn't work when
I have this code that is supposed to load the attributes of an XML
Ok. I have this little bit of code that is supposed to use text
I have this code that is supposed to take an array with some words,
I have this code that is supposed to echo some values from a MySQL
I have this piece of code that is supposed to work on Firefox 3.6
I have this code that's supposed to unzipp a file. public class dec extends
I have this code that make an image animation, but I want to call
I have quite a big code here... But fortunately it is not needed to
I have the code below that is supposed to draw lines from the top

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.