Search code examples
pythonpygamecursormouse

Pygame cursor blitting


I am currently working on a RPG game right now.And i need to blit a cool looking cursor for it but my actual cursor is blitted on the new cursor. How can i fix that?

import pygame,sys
from pygame.locals import *
pygame.init()
newcursor = "glove3.png"
display = pygame.display.set_mode((640,360),0, 32)
glovecursor = pygame.image.load(newcursor).convert_alpha()
while True:
    for event in pygame.event.get():
    if event.type == QUIT:
        pygame.quit()
        quit()
    display.fill((0,0,0))
    x,y = pygame.mouse.get_pos()
    x -= glovecursor.get_width()/7
    y -= glovecursor.get_height()/19
    display.blit(glovecursor,(x,y))
    pygame.display.update()

Solution

  • You can always create a sprite with its own image/surface and in its update function, just set its position to the current position of the cursor.

    self.pos = pygame.mouse.get_pos()

    But the above set_cursor() and pygame.cursors will work just fine.