i think the title is pretty clear but i'll try to get more into it.
我认为标题很清楚,但我会尝试进一步了解它。
so i created a game where you use the mouse to play, it's like the game labirynth. you can't touch the walls or you lose.
所以我创造了一个你用鼠标玩的游戏,它就像游戏labirynth。你不能碰到墙壁或丢失。
when i start the level i want the cursor to appear in it's starting position, which is a red picturebox, but i dont know how to...
当我开始关卡时,我希望光标出现在它的起始位置,这是一个红色的图片框,但我不知道如何...
here is the code i used:
这是我使用的代码:
Windows.Forms.Cursor.Position = New Point(679, 650)
Windows.Forms.Cursor.Position =新点(679,650)
as you can see there is a massive problem about this code.
正如您所看到的,此代码存在很大问题。
the location where the cursor appears is actuallt dependent of the resolution of the screen.
光标出现的位置实际上取决于屏幕的分辨率。
for example: with my monitor resolution, the location (679, 650) is right on top of the picturebox i need it to appear on. but if you have a different resolution on your monitor it will appear on a different place...
例如:使用我的显示器分辨率,位置(679,650)就在图片框的顶部,我需要它出现。但如果您的显示器上有不同的分辨率,它将出现在不同的地方......
i need to actually make it appear on top of the picturebox.
我需要实际让它出现在图片框的顶部。
i wish i could be clearer than this :(
我希望我能比这更清楚:(
1 个解决方案
#1
1
you can set your mouse location after taking the value of your picture position.
您可以在获取图片位置的值后设置鼠标位置。
x=picture1.left
y=picture1.top
Windows.Forms.Cursor.Position = New Point(x+somevalue,y+somevalue)
#1
1
you can set your mouse location after taking the value of your picture position.
您可以在获取图片位置的值后设置鼠标位置。
x=picture1.left
y=picture1.top
Windows.Forms.Cursor.Position = New Point(x+somevalue,y+somevalue)