I have a circle shape. I want it to hit the left side, then go to the right side, hit the right side, and then go left, I can get it to go left and stop, but not go back to the right. I am using object.move meth0d
Printable View
I have a circle shape. I want it to hit the left side, then go to the right side, hit the right side, and then go left, I can get it to go left and stop, but not go back to the right. I am using object.move meth0d
VB Code:
Private Sub TmrRight_Timer() Static NB as integer If NB = 4 then ImgBall.Left = ImgBall.Left + 200 If ImgBall.Left >= (ImgWall(1).Left - 375) Then TmrLeft.Enabled = True TmrRight.Enabled = False End If Else NB = NB +1 End Sub Private Sub TmrLeft_Timer() ImgBall.Left = ImgBall.Left - 200 If ImgBall.Left = (ImgWall(0).Left + 375) Then TmrRight.Enabled = True TmrLeft.Enabled = False End If NB = NB+1 End sub
Dont know if this will help... it's not using Object.move method, but It still works:
You need to add:
2 Images (the 2 walls) of 375 width
2 timers
Another Image (the ball that will bounce)
I cant get it to work, I want the ball to bounce between the 2 walls, I will work on this to see what I come up with though, thanks
Wow making a ball bounce is the hardest thing you can do in VB~@!!#
I hadn't tested it, now I did:
VB Code:
Private Sub TmrRight_Timer() Shape1.Left = Shape1.Left + 200 If Shape1.Left >= 3600 Then TmrLeft.Enabled = True TmrRight.Enabled = False End If End Sub Private Sub TmrLeft_Timer() Shape1.Left = Shape1.Left - 200 If Shape1.Left = 0 Then TmrRight.Enabled = True TmrLeft.Enabled = False End If End Sub
you need 2 timers, 1 shape
the code will not make your shape stop after 4 bounces though...
P.S. THIS CODE WILL MAKE YOUR CIRCLE BOUNCE WHEN IT REACHES LEFT: 3600
this works, thanks!!
np, if you want me to make it stop after 4 bounces i can get it to work, just tell me if you need me to do this