Animasi Form Visual basic/vb 6.0



Ketika Form Load [ muncul ]

- Form Melebar dari tengah ke samping

Beri tambahan timer pada form ( interval = 50)
Public Sub Tengah()
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
End Sub

Private Sub Form_Unload(Cancel As Integer)
Do
Me.Left = Me.Left + 40
Me.Move Me.Left, Me.Top
DoEvents
Loop Until Me.Left > Screen.Width
End Sub

Private Sub Form_Load()
Me.Width = 10
End Sub

Private Sub Timer1_Timer()
 Me.Width = Me.Width + 500
Tengah
If Me.Width >= 5000 Then
Timer1.Enabled = False
Tengah
End If
End Sub





- Form Melebar dari tengah ke samping
 
Beri tambahan timer pada form ( interval = 100)

Public Sub Tengah()
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2

End Sub

Private Sub Form_Load()
Me.Height = 10

End Sub

Private Sub Timer1_Timer()
Me.Height = Me.Height + 500 'ganti angka 500 sesuai dgn selera'
 Tengah
 If Me.Height >= 3000 Then 'sesuaikan dgn heigh form'
 Timer1.Enabled = False
 Tengah
 End If
 End Sub

Private Sub Form_Unload(Cancel As Integer)
 Do
 Me.Left = Me.Left + 100
Me.Move Me.Left, Me.Top
 DoEvents
 Loop Until Me.Left > Screen.Width
End Sub


Ketika Form Unload [ hilang ]


 - Form menutup ke atas atau ke bawah
 
Private Sub Form_Unload(Cancel As Integer)
 Do
 Me.Top = Me.Top – 5
 Me.Move Me.Left, Me.Top
DoEvents
Loop Until Me.Top > Screen.Height - 300
End Sub

 * untuk menutup kebawah ganti + pada " Me.Top = Me.Top - 5 "

 - Form menutup ke kanan atau ke kiri

Private Sub Form_Unload(Cancel As Integer)
 Do  Me.Left = Me.Left + 5 ' ganti angka 5 sesuai dgn selera'
 Me.Move Me.Left, Me.Top
 DoEvents
 Loop Until Me.Left > Screen.Width
End Sub
* untuk menutup kebawah ganti - pada " Me.Left = Me.Left + 5 "



- Membuat Animasi Teks 3D Berputar Dengan Visual Basic 6.0.

1. Bukalah proyek baru menggunakan Standard.Exe
2. Aktifkan Komponen DirectAnimation Library, dari menu Projects kemudian klik menu Componen.
3. Tambahkan objek DAViewerControlWindowed ( ) kedalam form, kemudian aturlah property name-nya dengan DAVCW

4. Sekarang masuklah pada halaman kode (klik View > Code) Kemudian tulislah program lengkap sebagai berikut.


Private Sub Form_Load()

Dim kanvas, half, Font, clr, bgr

Dim TxtAnimasi, pos, scl, xf

Set kanvas = DAVCW.MaterLibrary

Set half = kanvas.DANumber ( 0.5 )

Set clr = kanvas.ColorHslAnim(kanvas.Mul(kanvas.LocalTime,kanvas.DANumber (0.345)), half, half)

Set Font = Kanvas.Font (“comic sans ms”, 9 , clr)

Set TxtAnimasi = kanvas.StringImage(“Bunafit and Sister ’ s “, Font)

Set pos = kanvas.Mul( kanvas.Sin(kanvas.LocalTime),kanvas, DANumber (0.02))Set scl = kanvas.Add( kanvas.DANumber(2),kanvas.Abs(kanvas.Mul(kanvas.Sin(kanvas.LocalTime), kanvas.DANumber (3))))

Set xf = kanvas.Compose2(kanvas.Translate2Anim(kanvas.DANumber (0), pos), kanvas.Scale2UniformAnim(scl))

Set TxtAnimasi = TxtAnimasi.Transform(xf)

Set bgr = kanvas.Rotate3RateDegrees(kanvas.Vector3(1,1,1),45).ParallelTransform2

Set TxtAnimasi = TxtAnimasi.Transform (bgr)

DAVCW.backgroundImage= kanvas.SolidColorImage (kanvas.Yellow)

DAVCW.Image = TxtAnimasi

DAVCW.Start

End Sub

Setelah program dibuat, Anda dapat mencoba animasi di atas dengan menjalankannya. Apabila berhasil, maka teks “ Bunafi and Sister ‘s “ akan tampak berputar – putar seperti 3D.
Filed Under :
background