Bottom Page

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
Quote
#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))
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  creating sprite mask pfaber11 5 381 Jun-12-2019, 09:39 PM
Last Post: pfaber11
  [PyGame] pygame.draw.rect function stretches across the screen instead of moving BubblesTheGiraffe 2 288 Jun-11-2019, 08:32 PM
Last Post: metulburr
  [PyGame] Making Player Sprite Ricochet of walls michael1789 4 279 Jun-03-2019, 10:45 PM
Last Post: Windspar
  moving a sprite pfaber11 3 360 May-15-2019, 12:52 PM
Last Post: pfaber11
  Pygame Class Sprite Placement Confusion TheHumbleIdiot 2 640 Sep-11-2018, 02:19 PM
Last Post: TheHumbleIdiot
  [PyGame] How to stop the sprite's movement when it touches the edges of the screen? mrmn 5 1,843 May-13-2018, 06:33 PM
Last Post: mrmn
  [PyGame] Need Help With Sprite ghost0fkarma 2 803 Jan-09-2018, 02:14 PM
Last Post: ghost0fkarma
  [PyGame] Problem assigning positions on CC plane. Gengar 2 2,372 Sep-19-2016, 03:38 AM
Last Post: Gengar

Forum Jump:


Users browsing this thread: 1 Guest(s)