lordmauve / pgzero

A zero-boilerplate games programming framework for Python 3, based on Pygame.
https://pygame-zero.readthedocs.io/
GNU Lesser General Public License v3.0
527 stars 191 forks source link

Unable to change image of sprite #327

Closed jrmhaig closed 4 months ago

jrmhaig commented 6 months ago

When I try to use the image setter on an Actor I get the error TypeError: 'str' object is not callable. Here is a basic example that shows this;

import pgzrun

ship = Actor('ship0')
ship.image('ship1')

pgzrun.go()

Am I using this incorrectly? I'm afraid I am not primarily a Python programmer so it is possible I have misunderstood.

mrjonesmc commented 4 months ago

You need to use ship.image = 'ship1' ship.image is a property, not a function

jrmhaig commented 4 months ago

Thanks @mrjonesmc

This is very helpful and demonstrates my lack of knowledge of Python decorators.

jrmhaig commented 4 months ago

This is not an issue, just my misunderstanding.