multimedia ! graphics ! animation ! sound tip of the day 4 tip of the day: when using graphic...

24
Multimedia Graphics Animation Sound

Upload: lenard-white

Post on 28-Dec-2015

215 views

Category:

Documents


1 download

TRANSCRIPT

Multimedia

GraphicsAnimation

Sound

Tip Of the Day

Tip of the Day: When using graphic methods at Form Load, the AutoRedraw property of the container object must be set to True.

(Recall Test#3 - Student mark graph)

Circle Method (Revisited)

Me.Circle (x,y), radius

Circle Method (Arc)

Me.Circle (x,y), radius, , Start, End angle Angle measure are in radians

Circle Method (Pie Slice)

Me.Circle (x,y), radius, , -Start, -End angle Start and End angles must be negative

PaintPicture Method

The PaintPicture method is used to place an image in a certain location within a container

The syntax is as follows: object.PaintPicture object2.Picture, x, y

Cls Method

The Cls method is used to clear a container of all graphics drawn on it using the graphic methods.

The syntax is as follows: object.Cls

Using a Timer Object

The Timer method is used to execute code at specific time intervals.

A timer object ( ) can be used to simulate animation.

Properties: Name Interval Enabled

Timer Object Properties

Properties: Name Interval - is the amount of time (milliseconds)

before the Timer event is executed. It can be changed at runtime.

Enabled - can be set to either True or False. When enabled is True, the Timer event will be called. When Enabled is False, The Timer event will not be called.

Timer Event

The timer event occurs automatically after the amount of time specified in the Interval property.

After the code in the timer event procedure has been executed the timer object start counting down again.

Example of Timer

Private Sub Timer1_Timer()

If Me.BackColor = vbBlue Then

Me.BackColor = vbRed

Else

Me.BackColor = vbBlue

End If

End Sub

Moving Line Program

This program uses the timer event to change the endpoint coordinates of the line randomly after the amount of time specified in the Interval property.

Moving Line Example

Animation

Animation can be simulated by having several images on a form and then activating one image at a time.

For example, to animate a dolphin jumping, 3 pictures have been created at different points during the jump.

A timer object is used to control the speed of the animation.

Animation - Dolphin Jump

The 3 pictures can be placed in a control array (Click to see)

Animation - Control Array

A control array can be created by setting the Name property to the same value

For example: All 3 dolphin picture objects were named picDolphin and they were given index values 0, 1, 2 picDolphin(0) picDolphin(1) picDolphin(2)

Sound - Multimedia Object

A multimedia control can be used to add sound to an application. A multimedia object is created using the MMControl ( )

To add the Multimedia component if it does not appear in your tool box, follow these steps:

Sound - Multimedia Object

Step 1: Choose the Component from the Project menu.

Sound - Multimedia Object

Step 2:

Click here

Sound - Multimedia Object

Properties: Name DeviceType - changes the type of device that is playing

the sound. We will use .wav files, so the DeviceType is WaveAudio

Enabled - can be set to either True or False. True indicates the object can play sound.

FileName - used to select the file to be played Visible - establishes whether you can see the object at

runtime.

Sound - Multimedia Commands

Commands: Open - opens the mmcObject ready for playing Close - closes mmcObject. A multimedia object

should be closed before ending the application and must be closed before changing the FileName property.

Play - plays the sound track that was opened. Stop - used to stop the file to being played Prev - sets the sound track to its beginning.

Sound - Multimedia Object

Syntax: mmcObject.Command = Command Example of opening a multimedia object

Private Sub Form_Load()

mmcSound.DeviceType = "WaveAudio"

mmcSound.FileName = "Laser.wav"

mmcSound.Command = "Open"

End Sub

Sound - Multimedia Object

Syntax: mmcObject.Command = Command

Example of opening a multimedia object Private Sub Form_Unload(Cancel as Integer)

mmcSound.Command = "Close"

End Sub

Disco Dancer 2000

Check it out!

Summary

The following concepts were covered today: Shape Circles, Arcs and Pie Slices Picture Box vs. Image Box PaintPicture Move Method Animation Sound