Set Co-ordinates on game grid for each of the new sprite RRS feed

  • Question

  •     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            DoubleBuffered = True
            Sprites.Add(New Sprite)
            Sprites.Add(New Sprite)
            Sprites.Add(New Sprite)
            Sprites(0).Name = "Light Battle"
            Sprites(0).HP = 10
            Sprites(0).AP = 5
            Sprites(1).Name = "Heavy Panzer"
            Sprites(1).HP = 10
            Sprites(1).AP = 5
            Sprites(2).Name = "Heavy Scorcher"
            Sprites(2).HP = 10
            Sprites(2).AP = 5
            For i = 0 To 2
                Dim pic = New PictureBox()
                With pic
                    .Name = "Pic" & i.ToString
                    .Size = GridSize
                    .BackgroundImageLayout = ImageLayout.Stretch
                    Dim ImageFile As String = IO.Path.Combine("C:\Users\BusinessOffice1Room\Documents\", Sprites(i).Name & ".png")
                    .BackgroundImage = Image.FromFile(ImageFile)
                    AddHandler .MouseDown, AddressOf Pics_MouseDown
                    AddHandler .MouseMove, AddressOf pics_MouseMove
                    AddHandler .MouseUp, AddressOf pics_MouseUp
                End With
                Sprites(i).Pic = pic
                Sprites(i).ColRow = New Point(i)
            Form1_Resize(1, Nothing)
        End Sub

    In a nutshell, this code here creates the sprites from the given location and sets their point of all three selected sprites. 

    What I want to do is set the sprites location such as set one in position (3,4) and so on. 

    I tried writing Sprites(1).colrow = new point (4,5) but nothing happens 


    Sunday, March 26, 2017 12:44 PM


  • I found the answer after a good think

    I set the position before the for loop

    so Sprites(0).colrow = new point (3, 2) 

    BTW where are all the msdn people at today, chilling out in today's beautiful weather. I wish I could do the same but got coursework to finish first. 


    • Marked as answer by Waliur Rahman Sunday, March 26, 2017 1:15 PM
    Sunday, March 26, 2017 1:15 PM