Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Whirlatron |
This code fails because the variable ‘image’ is Null, and therefore does not have the method fill. Since get_data() is supposed to return an Image object why does it return Null?
extends Node2D
export var WIDTH = 200
export var HEIGHT = 200
func _ready():
var sprite = get_node(“Sprite”)
sprite.texture = ImageTexture.new()
sprite.texture.create(WIDTH, HEIGHT, 5)
var image = sprite.texture.get_data()
image.fill(Color(0, 0, 0, 1))