how to render sprites from a spritesheet

280 views Asked by At

I'm using python to develop a 2d game and am trying to use a spritesheet to optimize performance rather than storing/using dozens of separate sprites. The issue I'm having is after calling:

Image.crop((x, y, x+62, y+32))

I cant seem to use the return from the crop call to draw an image (canvas.create_image) and it doesn't seem to be a valid argument in creating a Photo Image.

I've looked online to try and figure out how I can use a cropped section of my spritesheet and render it on screen but all I find is pygame examples (I'm not using pygame in this project and adding it to take advantage of the blit function seems like the wrong way to go).

Does anyone have any recommendations on how I should go about cropping sprites from a spritesheet so I can render them to the canvas??

** Edit ** I figured it out, if I pass the crop return value as an arg when creating TkImage.PhotoImage (not just PhotoImage) it works fine

0

There are 0 answers