Python Forum
[PyGame] assigning rect to sprite - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Game Development (https://python-forum.io/forum-11.html)
+--- Thread: [PyGame] assigning rect to sprite (/thread-18445.html)



assigning rect to sprite - pfaber11 - May-18-2019

I've hit a brick wall .
How do I assign a rect attribute to a sprite . I'm out of ideas .
I'm using pygame.
This is the line of code I'm using to do this but it doesn't work. Could somebody show me a piece of code to do this .

Quote:image1_rect = image1.image.get_rect(topleft(x,y))

Thankyou


RE: assigning rect to sprite - metulburr - May-18-2019

im not sure what your image1 is versus image? But you would do

image = pygame.load.image('imagename.png')
rect = image.get_rect(topleft=(0,0))