The Cube Effect


In this example we are going to work with both images and get Image2 to expand and sqeeze Image1 basicaly a combination of  Shrink Right to Left and Stretch Right to Left. First I am going to set the initial possitions and also change the properties of the 2 images so that both images are stretched to fit the size of the image controls.
Sub object_name_OnLoad()

Image1.Left = 0
Image2.Left = Layout1.Width - 1

Image1.Width = Layout1.Width - 1
Image2.Width = 1

Image1.PictureSizeModeMode = 1
Image2.PictureSizeModeMode = 1

End Sub

All we have to do is stretch Image2 and shrink Image1 at the same time moving Image2 left.
Sub IeTimer1_Timer() 

Image1.Width = Image1.Width - (Layout1.Width / 20) 
Image2.Width = Image2.Width + (Layout1.Width / 20) 
Image2.Left = Image2.Left - (Layout1.Width / 20) 

If Int(Image1.Width) - 1 <= 1 Then 
    IeTimer1.Enabled = 0 
End If 

End Sub 

Notice that I use the width of the layout control Layout1 to calculate the decrement value. This is because it is the only static value available. Image1/2.Width changing each IeTimer1 is called.

You could enhance the timer routine to display random images on each face of the fake rotating cube. To do this you need to declare an array variable outside of any routine and fill it with your images. It can be any size but for simplicty I will make it 3 images big. Obviously though with 3 images it will not be very random.

Dim ImgArray(3)

ImgArray(0) = "images/image1.gif"
ImgArray(1) = "images/image2.gif"
ImgArray(2) = "images/image3.gif"

Sub IeTimer1_Timer() 

Image1.Width = Image1.Width - (Layout1.Width / 20) 
Image2.Width = Image2.Width + (Layout1.Width / 20) 
Image2.Left = Image2.Left - (Layout1.Width / 20) 

If Int(Image1.Width) - 1 <= 1 Then 
    Image1.PicturePath = Image2.PicturPath
    Image2.PicturePath = ImgArray(int(rnd*3))
    Call Layout1_OnLoad()
End If 

End Sub 

What happens here is that instead of dissabling the timer at the end, the image on Image2 (the big one) is put on Image1(the little one), a random image is set on Image2 and the OnLoad routine is called to reset the image controls to their initial state (making Image1 big).

 

 

 

© 1997 Chris Bayes For ClubSBN. All Rights Reserved.