Python Forum
[PyGame] Problem with colorkey
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] Problem with colorkey
#1
Hello, in one of my project I encounter a problem with pygame.set_colorkey,
I have a code like this, where Sprite is just a class to load and get Sprite
The problem is that even if the color of the background of my image is (194, 195, 196) the background is still blit on screen
from sprites import Sprite
import pygame as py
screen = py.display.set_mode((300, 300))
Sprite.load('button_icon', 'Ressources\\Sprites\\button_icon.png')
sprt = Sprite.get('button_icon', (256, 64), (128, 0, 64, 64))
sprt.set_colorkey((194, 195, 196))
print(sprt.get_at((0, 0)))
screen.blit(sprt, (0, 0))
running = True
screen.set_colorkey((194, 195, 196))
while running:
    for event in py.event.get():
        if event.type == py.QUIT:
            running = False
            break
    py.display.flip()
This is the result of the program
[Image: image.png]
Reply


Messages In This Thread
Problem with colorkey - by Phidias618 - May-14-2023, 08:27 AM
RE: Problem with colorkey - by deanhystad - May-15-2023, 03:44 AM
RE: Problem with colorkey - by Phidias618 - May-15-2023, 06:14 PM
RE: Problem with colorkey - by Windspar - May-15-2023, 08:22 PM
RE: Problem with colorkey - by Nivea04365 - Jun-09-2023, 08:44 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020