Error - Class 'SpriteKind' used before its declaration

Hi everyone!
I’m having this issue with an error for my player sprite. I’ve tried fixing it and trying different Python codes to fix it and nothing is working. Does anyone know how to fix this?

Thank you!


@jovanazekanovic can you share a link to your project? Use the share icon in the top bar (between the home and question icons)

here is the link :slight_smile:

ah, looks like your SpriteKind declarations got messed up.

SpriteKind is a special class in MakeCode’s Python, it needs to have the @namespace decorator on it to work properly. Try changing your declaration from:

class SpriteKind:
    bow = SpriteKind.create()
    crown = SpriteKind.create()
    ring = SpriteKind.create()

to

@namespace
class SpriteKind:
    bow = SpriteKind.create()
    crown = SpriteKind.create()
    ring = SpriteKind.create()

the SpriteKind class is the only one you need to add that decorator on; all other classes can be coded just like you normally would in Python.

awesone thank you so much! that fixed the error for me :slight_smile:

1 Like