May-14-2023, 08:27 AM
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
This is the result of the program
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
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() |
![[Image: image.png]](https://cdn.discordapp.com/attachments/754703407767486545/1107224949778808862/image.png)