Solved

Animation

Posted on 1999-01-19
7
319 Views
Last Modified: 2013-11-19
I would like an example of simple animation using a timer.
For example every half second a circle moves 10 pixels across the screen.
0
Comment
Question by:bradsoblesky
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 

Accepted Solution

by:
cdc_sickle earned 30 total points
ID: 1184563
void __fastcall TForm1::ExampleTimer(TObject *Sender)
{
short t;
ExampleTimer->Interval = 400;
t++;

if (t==5) t=1;

if (t==1) Ball->Left += 10;
if (t==2) Ball->Left += 10;  //blah blah, and so on, is this what you wanted?
//=+ is just, where the ball is, plus 10 more

}
//---------------------------------------------------------------
0
 

Expert Comment

by:cdc_sickle
ID: 1184564
this is a very simple way of doing it, i dont know if you wanted more coplicated, also, short t, would be declared in the program or form create lines, and same with the setting the interval of the timer
0
 
LVL 1

Expert Comment

by:MCoroli
ID: 1184565
There are several examples in C++ Builder3 and in Delphi.
They are enough simple.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:bradsoblesky
ID: 1184566
cdc_sickel could you please give great details.  For example lets say the ball is in a picturebox and I want to move the whole picturebox to make it look like the ball is moving.  I also have no clue where or in what file to put this in.  
Is this under the timers event calls or whatever?
0
 

Expert Comment

by:cdc_sickle
ID: 1184567
Hmm, ok, this is all timers, and are you saying an image box from a bitmap?

Ok, lets say you have your bmp in the same directory of the program your making. This file name is called Ball.bmp.
You place a timer, and a ImageBox on the form, and goto the code.
Right after the "#pragma resource "*.dfm""
Type
   short b;

b represents the Ball for the timer to work off of, as in the animation code i put above.

In the __fastcall of TForm1
put the following:

NameOfTimer->Interval = 400; //Anywhere from like 10 - 700 could do.

NameOfImageBox->Picture->LoadFromFile("Ball.bmp"); //Telling the Image box to be the Ball when the program starts

Also, have a button on the form...
In the OnClick property for that button, type:

NameOfTimer->Enabled = true; //Animation Start

Now, for the timer property's you type somthing like...



ExampleTimer->Interval = 400;
t++;

if (t==3) t=1; //This is a continuous loop, that would make the ball go right off the screen.

if (t==1) NameOfPicture->Left += 10;
if (t==2) NameOfPicture->Left += 10;  //blah blah, and so on, is this what you wanted?
//+= is just, where the ball is, plus 10 more



There are many ways of going about this, but this is a simple way that i found, you could also make another botton that has the code like

NameOfTimer->Enabled = false;
NameOfImage->Left = 70; //or what ever the picture started at.
0
 

Author Comment

by:bradsoblesky
ID: 1184568
Now thats what I'm talking about.  Thanks A Lot!!!
0
 

Expert Comment

by:cdc_sickle
ID: 1184569
He he, your welcome!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question