Hello. I am developing a game and for this game 2 of my sprites appear to be flying to the right. i have acomplished this by allowing an image box with the skay on to scroll accross my form from the right to the left. however, once the image has scrolled off the screen i can not get it to reset it self so that it it can scroll continuously.

back_star = my timer
sky = the image of the sky

Private Sub Form_Load()
back_star.Enabled = True
back_star.Interval = 1
End sub

Private Sub back_star_Timer()
back_star.Enabled = True
If back_star.Enabled = True Then
    sky.Left = sky.Left - 50
Else
    If sky.Left <=sky.Left -4920 then
    
    sky.Left = sky.Left + 0
End If
End If

End Sub

This is my code.

please could you take a look and show me where i have gone wrong or any alternative coding.

You must be using vb6.
Your timer logic is wrong.
1. when you come into the timer you are setting the timer enable and then checking to see if it is enabled. Which will allways be true.
2. The timer will not fire unless it is enabled which causes the above to happen again.
Try this code.

Option Explicit

Private Sub Form_Load()
    back_star.Enabled = True
    back_star.Interval = 1
End Sub

Private Sub back_star_Timer()
    sky.Left = sky.Left - 50
    If sky.Left < -sky.Width Then
        sky.Left = Me.ScaleWidth
    End If
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.