Solved

Animation

Posted on 1999-01-19
7
316 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sorting efficency of sorting algorithm 30 121
Swiper slider stops between pages 11 51
WCAG (Web Content Accessibility Guidelines) levels 3 100
Stupid git question 2 101
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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

809 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