python - Pygame screen.blit not working -


in program creating in python/pygame, screen.blit not working. in other programs have made, screen.blit works.

error:     traceback (most recent call last):   file "c:...\main.py", line 46, in <module>     screen.blit(sight.image, sight.rect) attributeerror: 'int' object has no attribute 'blit' 

the error in question caused screen variable being allocated integer instead of pygame.surface() object.perhaps accidentally rewrote variable somewhere?

from can make of doing, seems stating position of blit full rect instead of coordinate.

when do:

screen.blit(sight.image,sight.rect) 

what program seeing is:

screen.blit(sight.image,(sight.rect.x,sight.rect.y,sight.rect.width,sight.rect.height)) 

i assuming don't intend this. remember rect object consists of position, width , height.

to correct code, put (sight.rect.x,sight.rect.y) location goes instead this:

screen.blit(sight.image,(sight.rect.x,sight.rect.y)) 

the .x , .y correspond rect's upper left corners location in (x,y) pixel plane. sight image blitted in location.

if want read on the pygame.rect object, i'll post link it's documentation here

i hope helps. :)


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

c# - Web API response xml language -