Python Forum
[PyGame] assigning rect to sprite
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] assigning rect to sprite
#1
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
Reply
#2
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))
Recommended Tutorials:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] Rect object penetrates wall on one side Jan_97 4 2,462 Dec-30-2021, 11:08 PM
Last Post: Jan_97
  [PyGame] printing integers on pygame.draw.rect Shyckh 1 2,475 Aug-22-2020, 11:44 AM
Last Post: metulburr
  [PyGame] Sprite image.get_rect() moves sprite to 0, 0 michael1789 2 4,551 Dec-13-2019, 08:37 PM
Last Post: michael1789
  rect object not loading BlueClaw 2 4,107 Dec-11-2019, 04:25 PM
Last Post: BlueClaw
  Sprite not rendering Clunk_Head 2 2,095 Oct-03-2019, 11:27 AM
Last Post: Clunk_Head
  Need help making a sprite GalaxyCoyote 4 3,184 Aug-11-2019, 09:12 PM
Last Post: metulburr
  [PyGame] pygame.draw.rect function stretches across the screen instead of moving BubblesTheGiraffe 2 3,574 Jun-11-2019, 08:32 PM
Last Post: metulburr
  moving a sprite pfaber11 3 2,546 May-15-2019, 12:52 PM
Last Post: pfaber11
  [PyGame] Need Help With Sprite ghost0fkarma 2 3,252 Jan-09-2018, 02:14 PM
Last Post: ghost0fkarma

Forum Jump:

User Panel Messages

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