Solved

Animation

Posted on 1999-01-19
7
311 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
  • 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now