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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:27:18+00:00 2026-06-15T06:27:18+00:00

So, I have a rectangle rectangle1, at 160,160. I want it to move smoothly

  • 0

So, I have a rectangle “rectangle1”, at 160,160.

I want it to move smoothly to cordinates 160,30, with a duration of about 1 second. (time delay)

I’ve figured out that some basic code to move the shape is

rectangle1.Location = new Point(160,30);

However, when I tried doing a for loop with

rectangle1.Location = new Point(160, rectangle1.Location.Y - 100);

it just moved there instantly. Which I should have expected really. Same occurred with

int count = 0;
while(count != 300)
{
       rectangle1.Location = new Point(160, rectangle1.Location.Y -1);
       count += 2;
}

So, I assume I need some sort of clock / timer loop, that moves it by x pixels every x milliseconds. Not sure how to do this, so help would be appreciated.


Also, I’m going to be animating two other rectangles horizontally, which will then move up at the same time/speed as rectangle1. I think I’ll have to “delay” rectangle1’s movement until they are in position, correct?

Thanks.

PS: I’ve googled a fair bit, but since I’m not entirely sure what I’m looking for, it wasn’t very fruitful.

  • 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-15T06:27:19+00:00Added an answer on June 15, 2026 at 6:27 am

    If you need smooth movements, it’s great to use timers, threads, backgroundworkers.

    Here is what you need to do. Assuming you have the code that increment/decrement x,y points for the shape.

    Steps:

    • set timer interval to for e.g. 100

    • set an integer int count=0; *

    • in timer_tick event do the moving work

       private void timer1_Tick(object sender, EventArgs e)
       // no need to use your while loop anymore :))
        {       
         If(count< 300) //set to your own criteria
         {
           //e.g. myrect.location=new point(x,y);
           // rectangle1.Location = new Point(160, rectangle1.Location.Y -1);       
         }
      
          count += 2;
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rectangle which want to move using Canvas.SetLeft(rect, x); But I wanna
I want to position four div s relative to another. I have a rectangle
I have a rectangle and on my MouseMove event I want to transform the
I want to have rectangle that should have stroke only on left and right
Ok, So lets say i have a rectangle named rectangle1 and 2 labels named
For example, in a WPF or Silverlight app I have: <Rectangle Height=100 Width=200 Name=rectangle1
I have a simple screen in my iPhone app where I want a rectangle
I do have rectangle, which had information about topx, topy, width and height. I
I want to have a rectangle which has three different colors in flex. I
I have a rectangle which has known width and height.Now devide rectangle diagonally to

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.