Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Suicuiune |
My script can’t use functions defined in the extended class.
I have a script “res://scripts/tile.gd” with the code
extends Node2D
class_name tile
var cellPos: Vector2
var type: String
export var texture: Texture setget setTexture
func setTexture(newTexture):
self.texture = newTexture
update()
func update():
$Sprite.texture = self.texture
func _init():
var sprite = Sprite.new()
add_child(sprite)
update()
and an extending script “res://scripts/floor.gd” with
tool
extends tile
func _ready():
update() # error(6,1): The method "update" isn't declared in the current class.
It seems that for some reason floor doesn’t inherit any functions or variables at all since print(type)
also doesn’t work.
I have tested around a bit and believe it has something to do with the setget setTexture
or that functions are called from other functions.
I hope someone has also encountered this and knows how to fix it.
Thanks in advance for any feedback