Jul-26-2017, 04:56 AM
I mimicked this. If you look in the comments you can see I reworked the first example.
I set this at the very top
pygame.mouse.set_cursor((8,8),(0,0),(0,0,0,0,0,0,0,0),(0,0,0,0,0,0,0,0)) ##invisible mouseColorblack = (0,0,0)
From what you're saying I should do something like
WnY=pygame.image.load('whitenyellow.png').convert_alpha()
WnR=pygame.image.load('whitenred.png').convert_alpha()
outside of my mouse function, then
def mouse():
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONDOWN:
print("mouse down")
mouse_cursor=WnY
return
elif event.type == pygame.MOUSEBUTTONUP:
print("mouse up")
mouse_cursor=WnR
return
to avoid reloading the images constantly.*
Is there a good way to read the mouse consistently and fast and accurate?
I've also tried
I set this at the very top
pygame.mouse.set_cursor((8,8),(0,0),(0,0,0,0,0,0,0,0),(0,0,0,0,0,0,0,0)) ##invisible mouseColorblack = (0,0,0)
From what you're saying I should do something like
WnY=pygame.image.load('whitenyellow.png').convert_alpha()
WnR=pygame.image.load('whitenred.png').convert_alpha()
outside of my mouse function, then
def mouse():
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONDOWN:
print("mouse down")
mouse_cursor=WnY
return
elif event.type == pygame.MOUSEBUTTONUP:
print("mouse up")
mouse_cursor=WnR
return
to avoid reloading the images constantly.*
Is there a good way to read the mouse consistently and fast and accurate?
I've also tried
global b1 ex = pygame.mouse.get_pressed(0) if ex == (1, 0, 0) and b1 == False: b1 = True print("mouse down") mouse_cursor=pygame.image.load('whitenyellow.png').convert_alpha() print(ex)b1 is used to keep track if the mouse has switched images yet. I dont know if python/pygame works like this, but I figured once the image is set to be the "mouse" it sticks. So there's no reason to keep setting it 60x a second. With b1, once it's set to True, it's set and the if statement should skip it next time it's read. Right?