Godot Version
v4.4.1.stable.mono.official [49a5bc7b6]
Question
I am working on an android game and I want to see if I can make it run better. The game is a puzzle game where the board is made up of controls.
I currently have the project set to “compatibility” renderer based on this document.
Here is what the largest (11x11) board looks like:
This scene takes about 12ms to render on my phone:
The game board canvas layer has a control node that houses all the tile controls, and a camera2d for zoom/pan movement
If I set visible = false on the root control of the board, the Render Canvas step goes from 12ms to 2ms. So I think this is where a majority of the render time is coming from.
Each tile on the board is a control with several children, but most of them are not visible.
This is what the base tile template looks like:
However when I setup the board, I try to free/remove everything possible.
else if (tile.Type == YardSweeperTileType.Loot)
{
MyGrass.GuiInput += (inputEvent) => ClickTile(inputEvent, tile);
var CoinSprite = TileButton.GetNode<TextureRect>("CoinSprite");
CoinSprite.Visible = false;
CoinSprite.Texture = GD.Load<Texture2D>("res://art/coin" + tile.Value + ".png");
Label LootText = TileButton.GetNode<MarginContainer>("LootTextContainer").GetNode<Label>("LootText");
LootText.Text = tile.Value + "";
var SkullSprite = TileButton.GetNode<CanvasItem>("SkullSprite");
SkullSprite.Visible = false;
var GraveTextContainer = TileButton.GetNode("GraveTextContainer");
TileButton.RemoveChild(GraveTextContainer);
GraveTextContainer.Free();
var GraveSprite = TileButton.GetNode("GraveSprite");
TileButton.RemoveChild(GraveSprite);
GraveSprite.Free();
var VeinSprite = TileButton.GetNode("VeinSprite");
TileButton.RemoveChild(VeinSprite);
VeinSprite.Free();
var RockSprite = TileButton.GetNode("RockSprite");
TileButton.RemoveChild(RockSprite);
RockSprite.Free();
}
Because of this, all the tiles should only have visible what is necessary to draw. While there are layers (coins below grass and above dirt), those are all visible = false, and removed and freed when possible.
So far I have tried changing out the TextureRects for Sprite2Ds, but I did not measure a performance change.
Is this normal performance for rendering ~200 textures on android? Are there any rendering improvements that I can make to this setup? thanks.