[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] mouse.set_pos(mouse.get_pos())?
Hello,
I'm trying to make a animation which may involve moving the window
around, but I want to keep the mouse in the same "virtual" place. I've
got the following snippet:
xoff = (xres - xpos) / 2
yoff = (yres - ypos) / 2
x, y = pygame.mouse.get_pos()
x += xoff; y += yoff
xpos += xoff; ypos += yoff
pygame.mouse.set_pos((x,y))
I expected this to move the mouse along with the animation (which it
does), but it also keeps the mouse pegged at it's original position. In
other words, when I move the mouse it springs immediately back to where
it was - get_pos() doesn't seem to reflect the fact that the mouse has
moved. If I remove the call to set_pos and print the value of get_pos
then it changes, but if I add the call to set_pos back in, the value
stays fixed when xoff = yoff = 0
Any thoughts?
--Mike