Existing Qiso character spritehseet load and swap

Hi!

This question is about Qiso isometric engine.
To create a character we need to load a spritesheet. Also, we can unload this recently loaded by .remove and set it’s reference to nil. Okay.

But we are bound to use Qiso .addCharacter() function instead native sprite and it is requesting a spritesheet to work with. But I found no functions to change this spritesheet without creating a new character. To dinamically load another spritesheet we need to destroy the old and add a new one.

If we are NOT talking about pixel art games:

one 180x180 frame use 180w * 180h * 4rgba bytes ≈ 130KB of video mem.
animations are of 12…24 frames length (16 average)
130 * 16 ≈ 2 Megabytes per animation.
To have smooth isometric result i’m using 16 directions with 22.5 degree step
2 * 16 ≈ 32 MB per animation
Each character/monster has at least 3 attack + 1 death + 1 hit + 1 idle + 1 run animations
32 * 7 ≈ 220 Megabytes per ONE viable
Each frame you can render up to 5 viable(s) - Player(s)+Mobs.
This turns in a gygabyte of mem without taking into count tilemap with many layers, props, sprites, etc.
And 4 Gigs for modern resolution and 320x320p sprites.

So from ancient ages all RPGs are loading sprites dinamically, with culling, player view radius logic processing and this way I did it on other engines.

So I’m wondering if you, guys, have some optimized/tested strategy how to do this in a best way?
Best way to realtime load and swap to another spritesheet for Qiso character?
The bruteforce way is seen as to create another character with another spritehseet and just swap it’s visibility with old one (and destroy it in background). Seems much more effective would be to change internal link to other spritesheet or so?

Forgive me my dumb question, I havent dived under the hood of Qiso yet. Thanks in advance for all answers!

Hi,

This isn’t tested, admittedly, but under the hood Qiso’s addCharacter function creates data within an associative array using the given character ‘name’ as the assoc ID, so if you just call addCharacter() multiple times, using the same character name each time, this should at least theoretically replace the one character in memory, which seems to be what you’re trying to do here?

Additionally, you can use getCharacterData() to get the current data stored at that assoc array location, so you’re able to grab the current x,y coordinates for example, to feed back in to the new addCharacter() call, positioning said character at the same location as the original.

The addCharacter() function itself is essentially just a data push - it doesn’t do anything taxing beyond calling display.newSprite() which you’d need to do even if just swapping out the sheet on the existing character data, so I don’t think there’d be any performance implications with going this route.

1 Like

Thank you very much for explanation! I will dive in this direction! Very appreciate!

1 Like