All objects in Delphi provide four attributes: Top, Left, Height, and Width to control the position and size of the object; in addition, a Time component is also provided in Delphi, which can easily implement some animations.
Arc ⒗ Curtain
The curtain sermon slowly displays the screen from the middle to both sides. Here, set the center property of dbimage1 to true; set the stretch property to false. Set the Width property to 0 and set the value of Left appropriately to make it appear in the middle of the screen. The main method to implement animation is to modify the Left attribute (the value gradually becomes smaller) and the Width attribute (the value gradually becomes larger). It should be noted that in order to pull the curtain evenly from the middle to both sides, the Width change value must be the Left change value. 2 times. Enter the following statement in the OnTime event of Dimeer1:
if (dbimage1.left>0) then
Begin
dbimage1.left:=dbimage1.left-1;
dbimage1.width:=dbimage1.width+2;
//The change value of dbimage1.width must be 2 times the change value of dbimage1.left
end
else
timer1.enabled:=false;//Take end.
Change Left in the above program to Top and Width to Height to achieve vertical curtain pulling. If the effect of pulling the curtain is applied to the text type object, the image is very good.
,accordion
In the animation of the Eye-Shijing, when the entire screen is displayed, the screen is slowly blocked from both sides to the middle, and it continues to cycle, like playing an accordion. When implementing, a variable State needs to be added to indicate the state at this time. The specific procedures are as follows:
procedure TForm1.Timer1Timer(Sender:TObject);
Begin
If state=1 then
if (dbimage1.left>0) then
Begin
dbimage1.left:=dbimage1.left-1
dbimage1.width:=dbimage1.width+2
end
else
// When the screen is completely opened, change the state variable
state:=2
else // Pull from both sides to the middle
if dbimage1.left<form1.width div 2 then
Begin
dbimage1.left:=dbimage1.left+1;
dbimage1.width:=dbimage1.width-2;
end
else
// When the screen closes, change the state variable
state:=1;
end;
, fence type
The surface is initially blocked by vertical fences, and then the fences gradually narrow, and the picture divided by the fences gradually becomes complete. In this animation, the role of the fence is acted as an object of the STATICTEXT type (the screen displays several fences and requires several STATICTEXT objects). Just change the Left and Width properties of the STATICTEXT type object (Left gradually becomes larger and Width gradually becomes smaller). On the onClick event of Timer1, each STATICTEXT object is processed as follows:
if st1.width>0 then //ST1 is an object of type STACTICTEXT
Begin
st1.width:=st1.width-2;
st1.left:=st1.left+1;
end
else
//Run again
Begin
st1.width:=40; //Width and Left are determined by the actual situation
st1.left:=40;
end;
Arrange the fences above horizontally, change Left to Top, and Width to Height, which will become the effect of a hundred-page window. If you are interested, you can try it.
G⒎ Page
The effect of resuming the transition is actually to fix the Top value, change the Height value, and set the Stretch value to True. Type the following program in the OnTime event of Timer1 to turn pages up:
if dbimage1.height>0 then
dbimage1.height:=dbimage1.height-4
The attribute value of Height of Yanxiaping Machinery changes from small to large, so that the effect of turning pages downwards is achieved. If you change Top to Left and Height to Width, you will achieve the effect of turning pages left and right. If Left and Width are changed at the same time, the picture can be rotated with a vertical line passing through the picture as the axis. In the OnTimeR event of Timer1, the program is as follows:
procedure TForm1.Timer1Timer(Sender:TObject);
Begin
if state=1
Then
if dbimage1.width>0 then
Begin
//The picture gradually becomes smaller
dbimage1.left:=dbimage1.left+1;
dbimage1.width:=dbimage1.width-2;
//The change value of width must be twice the change value of left
end
else
state:=2
else
if dbimage1.width<250 then
Begin
dbimage1.left:=dbimage1.left-1;
dbimage1.width:=dbimage1.width+2;
end
else
state:=1
end;
From the above program, we can see that this is to make the picture smaller and then gradually grow larger. To make the smaller is one state (State=1), and to make the narrower is another state (State=2). These two states appear alternately. Animation will appear.
⒋Ping gradually moves (fly) across the face
The effect of letting the title fly across the picture is often needed. To implement this type of animation, you only need to change the title's Top (Flying vertically) or Left attribute (Flying horizontally).
If you realize a title flying from left to right on a painting. First create a graphic object Dbimage1 and a text object Statictext1 in Form1 (note that TEXT type objects cannot be displayed on the picture), set the position and size, and then create a Time object Time1 in Form1, set its Enabled property to Set TrueInterval property to 10; and type the following statement in event OnTime:
procedure TForm1.Timer1Timer(Sender:TObject); begin
if statictext1.left<dbimage1.width+dbimage1.left then
statictext1..left:=statictext1.left+3
else
statictext1.left:=dbimage1.left;
//When the title flies out of the picture, make the title relocate to the left of the picture, and enter the screen from left to right again
end;
Get a bird
1. If you want to move the title from left to right only once, change the Else statement to Timer1.enabled:=false;
2. The value 3 is the speed value of the title movement and can be changed at will;
3. If the title is moved to a certain position in the picture, change "statictext1.left<dbimage1.width+dbimage1.left" to "statictext1.left<position value", and change the Else statement to Timer1.enabled:= false;
4. Just change the value of Left from large to small, and then fly from right to left;
5. Change the Left above to Top and Width to Height to achieve vertical animation.