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 7178107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:51:14+00:00 2026-05-28T16:51:14+00:00

I have a rectangle with a percentage 1.0f this means 100% so at certain

  • 0

I have a rectangle with a percentage 1.0f
this means 100%
so at certain point i set this percentage to 0.0f in another function by mouse click
and now to fill the rectangle back to 100% or 1.0f is where the problem is
I see the rectangle growing back up but never in the right time (time_to_fill_in_seconds)
on update i have the following

    private void updateInterface(GameTime gameTime)
    {
        this.newGameTime += gameTime.ElapsedGameTime.Milliseconds;

        if ((rectangle.getPercentage() == 0) &&
            (rectangle.getAddValue() == 0))
        {
            float time = 1000 * time_to_fill_in_seconds;

            // update rectangle add values
            rectangle.incrementToIn(1.0f, time);
       }

       rectangle.Update(gameTime);
    }

and inside rectangle

    // Value to be added on each Update
    public void incrementToIn(float targetPercentage, float time)
    {
        setAddValue((targetPercentage - currentPercentage) / time);
    }


    public override void Update(GameTime gameTime)
    {
        if ((percentage <= 1.0f) && (addValue > 0))
        {
            if (percentage == 1.0f)
                addValue = 0;
            percentage += addValue;
        }
    }

I already lost like 2 days searching for the problem…
The bar takes too long to fill
what am i doing wrong?

this is probably something very simple…
if you see something wrong I appreciate your help
thank you

  • 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-05-28T16:51:15+00:00Added an answer on May 28, 2026 at 4:51 pm

    Pheraps I am wrong but it seems that percentage won’t never be 0. In fact Update sets addValue to 0 but not percentage.
    Moreover I suggest you to replace the test
    percentage == 1
    with
    percentage >= 1.

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

Sidebar

Related Questions

I have a rectangle that looks like this <Rectangle x:Name=rect Width=76 Height=76 HorizontalAlignment=Left> <Rectangle.Fill>
Suppose you have have a rectangle, bottom-left point 0,0 and upper-right point is 100,100.
I have a rectangle that I've created and set its individual properties like so
I have a transparent rectangle on a picture box,if i click next,the next image
I have rectangle, which fill color is determined by MultiBindingConverter from RGB-sliders. <Rectangle.Fill> <SolidColorBrush>
I have created rectangle shapes using onDraw method, filled with single colors. Now I
Lets say i have a rectangle Now i wish to apply it transformations such
I have a Rectangle which can be dragged within some boundaries. This works perfect
I have a rectangle that i want to fill with a color. When i
In WPF, I have rectangle like this: <Rectangle Grid.Column=1 Name=rectangleSignal HorizontalAlignment=Left Width=20 Height=20 >

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.