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

  • Home
  • SEARCH
  • 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 8224729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:10:13+00:00 2026-06-07T15:10:13+00:00

been fighting with this problem for a good 3 hours now, and i figured

  • 0

been fighting with this problem for a good 3 hours now, and i figured it was finally time to ask some professionals.

My problem is that i want to make a scrollbar, and I’ve figured out that i want to make it by using two integers and then give every item in the list an ID, and then say that all the items that has an ID thats in between the two integers are going to be shown, and then afterwards make 2 buttons that will + or – the integers so you can “scroll” though the items.

So to realize this i decided to make dummy code, to see how i could work it out.
And for most part its working, however i have the problem now, that it seems that my draw function is refreshing the screen constantly (Even though I’ve put in a bool to make sure it woulden), and by doing that it keeps erasing the numbers I’m listing on the screen.

Heres the code:

List<int> test = new List<int>() {1,2,3,4,5,6,7 };

        int low = 0;
        int high = 3;
        int count;
        bool isDone = false;

 public override void Draw(GameTime gameTime)
        {
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null);

if (!isDone)
            {
                int posX = 20;
                foreach (int nr in test)
                {

                    if (count == high)
                    {
                        isDone = true;
                        break;

                    }
                    else
                    {
                        count++;
                    }
                    if (count >= low && count <= high)
                    {
                        posX += 20;
                        spriteBatch.DrawString(gameFont, nr.ToString(), new Vector2(posX, 20), Color.White);
                    }
                }
            }

 spriteBatch.End();

}

Hopefully some of you clever folks can eye the mistake I’ve been missing.

Thanks in advance

~Etarnalazure.

  • 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-07T15:10:16+00:00Added an answer on June 7, 2026 at 3:10 pm

    You never reset your counter. Therefore, the numbers will be only visible in the first frame. Add

    count = 0;
    

    before the for-loop.

    Furthermore, you might want to revise your structure. If you use a List<>, then every item already has its index. And you don’t have to iterate over each and every item, if you use a for loop:

    for(int i = low; i <= high; ++i)
    {
        var currentItem = list[i];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been fighting this problem for many hours now and could really use some
I've been fighting this crazy problem for hours and have gotten nowhere. I have
I have been fighting with this for quite some time and have found a
Good evening, I am tired and have been fighting with this for hours. I
For the last 2 hours I have been fighting with this problem and trying
i have been fighting with this code for a few hours now.... Sample Node
I've been fighting with this PHP-snippet for some hours and I can't figure it
I have been fighting for like 6 hours with this now. I have followed
I've been fighting with this problem all day and am just about at my
I have been fighting this problem with the help of a RegEx cheat sheet,

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.