简体   繁体   中英

Image Resizing/Scaling

trying to make a rock paper scissors and wanted to make a window, everything so far works except the size of the image, it's also not centered.

pygame.transform.scale = pygame.image.load('/Users/louistenant/Library/Mobile Documents/com\~apple\~CloudDocs/Code_RPS/Rock.jpg' ),(10 , 5)

pygame.transform.scale = pygame.image.load('/Users/louistenant/Library/Mobile Documents/com\~apple\~CloudDocs/Code_RPS/Paper.jpg' ),(10 , 5)

pygame.transform.scale = pygame.image.load('/Users/louistenant/Library/Mobile Documents/com\~apple\~CloudDocs/Code_RPS/Scissors.jpg' ),(10 , 5)

I tried adding this but nothing changed(first image is code and the second one is the window.)

code

output

You are using the right functions, but the wrong syntax. Instead of

pygame.transform.scale = pygame.image.load('/Users/louistenant/Library/Mobile Documents/com\~apple\~CloudDocs/Code_RPS/Rock.jpg' ),(10 , 5)

do

image = pygame.image.load('/Users/louistenant/Library/Mobile Documents/com\~apple\~CloudDocs/Code_RPS/Rock.jpg' )
image = pygame.transform.scale(image, (10 , 5))

As for not being centered, pygame draws from top left I believe, so you need to shift the position you specify accordingly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM