Try Ball.Location = new Point( 266, 338 ).
How to move a PictureBox back to the original starting location?
I am currently working on a game right now, which involves a ball (PictureBox), a paddle, some blocks and borders. The game board contains 4 borders: a top border, a left border, a right border, and a bottom border. The bottom border is the part that I am meant to focus on. Basically, when my ball touches the bottom border, it will freeze. The idea behind it is that the ball will freeze for a few seconds and then it will go back to the ball's original starting location. However, so far, I have unfortunately been unable to find a way of doing this. I have tried using Ball.Location (Ball is the name of the PictureBox), and then putting the ball's starting coordinates in brackets, however, I am getting this error:
BC30311 Value of type '(Integer, Integer)' cannot be converted to 'Point'.
Here is a snippet of the area of code which is causing the issue:
The first 3 lines are fine, it is the 4th line which is causing me issues. The 'Ball.Location' part seems to be fine, but when I input the values into the brackets, I get an error. I'm assuming that I would need to convert the values to 'Point' type instead of Integer, but I don't know how to do it.
(I should also mention that both the ball AND border are PictureBoxes).
1 additional answer
Sort by: Most helpful
-
Xingyu Zhao-MSFT 5,356 Reputation points
2021-11-03T02:05:04.307+00:00 Hi @GG01Coding-3690 ,
You can define a point to record the original starting location of the ball,Dim oriPoint As New Point oriPoint=Ball.Location
Every time you want to move a PictureBox back to the original starting location, just:
Ball.Location = oriPoint
Best Regards,
Xingyu Zhao
*
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.