943,608 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 1902
  • VB.NET RSS
Mar 14th, 2009
0

Marquee image box

Expand Post »
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

VB.NET Syntax (Toggle Plain Text)
  1. Private Sub Form_Load()
  2. back_star.Enabled = True
  3. back_star.Interval = 1
  4. End sub
  5.  
  6. Private Sub back_star_Timer()
  7. back_star.Enabled = True
  8. If back_star.Enabled = True Then
  9. sky.Left = sky.Left - 50
  10. Else
  11. If sky.Left <=sky.Left -4920 then
  12.  
  13. sky.Left = sky.Left + 0
  14. End If
  15. End If
  16.  
  17. End Sub

This is my code.

please could you take a look and show me where i have gone wrong or any alternative coding.
Last edited by Razza92; Mar 14th, 2009 at 11:20 am. Reason: missed some code
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Razza92 is offline Offline
6 posts
since Mar 2009
Mar 15th, 2009
0

Re: Marquee image box

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.
VB.NET Syntax (Toggle Plain Text)
  1. Option Explicit
  2.  
  3. Private Sub Form_Load()
  4. back_star.Enabled = True
  5. back_star.Interval = 1
  6. End Sub
  7.  
  8. Private Sub back_star_Timer()
  9. sky.Left = sky.Left - 50
  10. If sky.Left < -sky.Width Then
  11. sky.Left = Me.ScaleWidth
  12. End If
  13. End Sub
Reputation Points: 84
Solved Threads: 58
Posting Pro in Training
waynespangler is offline Offline
461 posts
since Dec 2002

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Problem while Inserting and Updating data into MS access
Next Thread in VB.NET Forum Timeline: Get Files of Recycle Bin





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC