Thank you TwistedTwigleg. :)
I think the issue is a tension between the setget syntax and the fact that you can't redeclare an inherited member variable. According to the documentation, setget has to come directly after the declaration, but I can't redeclare the variable in the child node. Just writing position setget _set_position
gives an error as expected.
I don't know whether there are deeper reasons why you can't add accessors to an inherited variable or this is just something that can't be expressed with the current syntax.
If I used a different variable name it wouldn't give me the desired behavior. :) I want the accessor to be called when the sprite moves around.
@Megalomaniak said:
So the above code is attached to the parent only, or did you try to attach it also to the child?
The code is attached to the sprite node. The variables are inherited from an ancestor, I believe Node2D.