Reputation: 122
So I have a small part of my program here:
import pygame
class image(object):
def __init__(self, src):
self.name = pygame.image.load(src)
print self.name
def resize_img(img_name, new_length, new_height):
img_name = pygame.transform.scale(img_name, (new_length, new_height))
robot_img = image("lolz.png")
robot_img.resize_img(robot_img.name, (30, 30))
And I get this error:
TypeError: must be pygame.surface, not image
What is going on? Any help is much appreciated, and, if needed, I will happily give more information.
Upvotes: 0
Views: 43
Reputation: 142651
You forgot self
in resize_img
def resize_img(self, img_name, new_length, new_height):
BTW: you have to use length
and width
without ()
in
robot_img.resize_img(robot_img.name, 30, 30)
Upvotes: 1