New to Godot - working on my first card game. I’ve been testing my game on lower-tier Android devices and I have come across some serious performance issues. In researching I came across the recommendation of using an Atlas for my images. I want to use an Atlas for my 50+ card images, but is this the most efficient way to do so?
var atlas_image = Image.new()
atlas_image.load("res://Assets/Atlas/AtlasCards.png")
Card #1:
var card_1_image: AtlasTexture = AtlasTexture.new()
var card_1_texture = ImageTexture.create_from_image(atlas_image)
card_1_image.atlas = card_1_texture
var card_1_region = Rect2(Vector2(0,0), Vector2(100, 150))
card_1_image.region = card_1_region
Card #2:
var card_2_image: AtlasTexture = AtlasTexture.new()
var card_2_texture = ImageTexture.create_from_image(atlas_image)
card_2_image.atlas = card_2_texture
var card_2_region = Rect2(Vector2(100,0), Vector2(100, 150))
card_2_image.region = card_2_region
Then I assign:
%Card_1.texture = card_1_image
%Card_2.texture = card_2_image
This is supposed to increased the performance, less memory for images. However, compared to current method where I just have a single image saved in my Assets folder and make an assignment like so:
%Card_1.texture = preload("res://Assets/image_card_one.webp")
%Card_2.texture = preload("res://Assets/image_card_two.webp")
The option to use an Atlas seems far more complicated, especially since I have to now create/use 3 variables to make an image assignment - or 100+ to make assignments for each card. So I was wondering if my above setup was correct. It works, but is it the most efficient way to make the image assignments using an Atlas? Thanks.