Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Launching Projectile [Game Issue]
#9
Everything works until one bullet reaches the end of the form.
Code:
Public Sub PlayerBullets_Act()
        'This method moves the player bullets and detects their collisions. It should be called every
        'time the timer ticks
        For Each bullet As PictureBox In playerBullets
            If (bullet.Location.Y <= 0) Then
                'The bullet has moved off of the screen, we need to remove it to conserve system resources
                Controls.Remove(bullet)
                playerBullets.Remove(bullet)
            End If

            'TODO: Check for collisions with enemies here

            bullet.Location = New System.Drawing.Point(bullet.Location.X, bullet.Location.Y - 2) 'Move the bullet up
        Next


    End Sub
The problem is at the Next. This is what I get:
Quote:Collection was modified; enumeration operation may not execute.
Also known as Rocketalypse.
System.out.println("I prefer Java.");


Messages In This Thread
Launching Projectile [Game Issue] - by Vinwarez - 07-13-2012, 01:08 PM
Re: Launching Projectile [Game Issue] - by Vinwarez - 07-13-2012, 02:57 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Full screen game overlay? Ecnarf 1 8,214 01-29-2013, 09:14 AM
Last Post: xolara
  Dual Menu Strip Issue Moldraxian 3 16,100 08-15-2012, 12:36 PM
Last Post: brandonio21
  MySQL Database Issue Moldraxian 7 27,880 08-13-2012, 08:58 PM
Last Post: brandonio21
  Module Issue Vinwarez 18 56,385 07-24-2012, 11:47 PM
Last Post: Vinwarez
  Remove Enemy [Game Issue] Vinwarez 3 13,778 07-14-2012, 02:15 PM
Last Post: brandonio21

Forum Jump:


Users browsing this thread: 1 Guest(s)