[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Animation

Posted on 1999-01-19
7
Medium Priority
?
322 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 120 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

649 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