TextureLoader.gd 654 B

123456789101112131415161718192021222324252627282930
  1. extends Reference
  2. var filePrexif = "user://colorTiles"
  3. # Called when the node enters the scene tree for the first time.
  4. func _ready():
  5. pass # Replace with function body.
  6. func loadTexture(lat, lon):
  7. lat =int(lat)
  8. lon = int(lon)
  9. var texName = getTexName(lat, lon)
  10. print(texName)
  11. var image = Image.new()
  12. var err = image.load(texName)
  13. if err != OK:
  14. print("error opening tex ", err)
  15. var tex = ImageTexture.new()
  16. tex.create_from_image(image, 0)
  17. return tex
  18. func getTexName(lat, lon):
  19. return "%s/m-%s-%s.png" % [filePrexif, lat, lon]
  20. # Called every frame. 'delta' is the elapsed time since the previous frame.
  21. #func _process(delta):
  22. # pass