All Questions


posted to: Wiring entities

Debugger is complaining with warnings

In the file, in the "_finished_deconstruct" definition, why do we need to declare an "entity" variable since it is never used ?

Also in, I can't get if it's the parameter "sprite" or the class variable "sprite" that is in use.

  • Razoric replied

    1. The entity variable is used in the future as we delve into inventory, dropping entities to the ground (and thus need to know what we just deconstructed so we can put a ground item there), and that sort of thing. If the warnings bother you, you can, for now, comment out the unused line, or put an underscore in front of entity ("_entity") and Godot will stop raising warnings about unused variables.

    2. "set_sprite_for_direction()" is a static function. That means it's a function that belongs to the class, not the object. The sprite property is not static, and so belongs to the object (that's created from the class.) You cannot get to the sprite property from a static function, which is why we pass in a parameter.

    Hope that clears things up a little. Let me know if you need more clarification.

  • Etilem replied

    Yes thank you, that is most clear now !