Jul-26-2017, 10:53 PM
(Jul-26-2017, 12:47 PM)Mondaythe1st Wrote: I need to be able to switch the image inside a Def depending on the mouse being press or released.
Then all you need to do is check if the mouse is down. This modification of my example shows the mouse cursor when not held down, and the image when is held down.
import pygame as pg screen = pg.display.set_mode((800,600)) screen_rect = screen.get_rect() done = False cursor_img = 'curs.jpg' cursor = pg.image.load(cursor_img).convert() cursor_rect = cursor.get_rect() is_cursor = False while not done: screen.fill((255,0,0)) for event in pg.event.get(): if event.type == pg.QUIT: done = True if pg.mouse.get_pressed()[0]: is_cursor = True pg.mouse.set_visible(False) else: is_cursor = False pg.mouse.set_visible(True) cursor_rect.center = pg.mouse.get_pos() if is_cursor: screen.blit(cursor, cursor_rect) pg.display.update()
Recommended Tutorials: