I have a spritesheet of monsters that I have used for my first game, Eye of the Beerholder, that realized in Godot.
The spritesheet contains 170 rows of sprites, each row of 5 frames. They all share the same animation sequence: 3 are used for the walk animation and 2 for the attack animation, always in the same order.
Thanks to this, in Godot I am able to use an only “monster” object; chosing and integer in the range 0-169, I can fix the row, thus the monster type: a goblin, a wolf, a skeleton, etc. This number also allows me to pick data from an array, retrieving the monster name, HP, damage, walk speed, range of attack, projectile type… a lot of stuff indeed.
I wonder if this can be done in Gdevelop. I do NOT want to have to code 170 different object types, all with the same basic behaviour and animations: I would like to do it only at once, with the same code in the same object, picking up an index just as in Godot.
But to begin with, I don’t even understand how to use the spritesheet in such a way.
GDevelop uses a single image per animation. It can’t do sprite sheets. There are a couple of possible ways to get around this:
Use Sprite Animation Helper plug-in for Paint.net to break up the sprites into individual images, and load these into a sprite object for each animation sequence. You could name the animations “Walk1” for walk animation for monster1, “Attack1” for attack animation for monster1, “Walk2” for monster 2 etc. You then set the animation referencing the walk animation name as “'Walk' + ToString(MonsterNumber)”, and similarly for the attack animation (“Attack' + ToString(MonsterNumber)”) where MonsterNumber is a variable for the monster’s number/id. This would require one sprite object.
Use the sprite sheet as is in a Tiled Sprite object. If all the sprites are the same dimensions, you then set the tile size to those dimensions, and use the x and y offsets calculated on the frame number and monster number. This uses one tiled sprite object, but you’d have to manage the animation by changing the offsets with events.