• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

Creating sprites in code vs in gms2 gui normaly

tylerbertz

Member
Iv been creating sprites the traditional way by clicking create sprite and add image. But I'm wanting to build a launcher to download/update my game now. and it seems the best way is to have all my sprites seprete.
But I have a feeling that if I load in all my sprites by code, it will be slower than adding then directly.

And if I do creat sprite throw code Should sprite be added as there used and released/freed when done or should I just load all sprites at the beginning with a load bar.
 

Tyg

Member
I would have all the game sprites included in the game because if they are loaded using sprite_add they are not packaged with the exe as they are not compiled into it
and any original artwork is not encrypted within the exe
Then have an update function if you want to add or change sprites in future updates, if you just change the sprite, say a cooler sword anim, it can still be attached to the object just a sprite load and change
Your update file would have the name of the sprite to load and object it is replacing the sprite of
There really is no vs here, it depends on how you want to design and package your game
But if there were alot of changes i would just go Version2.0 :)
 

tylerbertz

Member
with this method for an update wouldn't i have to send the full game every time to update? or are you saying its posable to send data.dlc that can actualy edit the exe like for instance add 1 object new_enemy and 1 sprite new_enemy && replace sprite Player_sword with sprite Player_better_sword?
 
Last edited:

Tyg

Member
Yes you would do a new_sprite = sprite_add("new_sprite.png",0) to bring in the external sprite.
Get the index, new_sprite_index = sprite_get_index(new_sprite);

every object or instance has a sprite_index
so sword.sprite.index = new_sprite_index :)

and as by Update i meant as a function like new version is out and you want to update, maybe an option in a menu
 

tylerbertz

Member
basically your saying I ether have sprite's internally and have user redownload complete game.
or have sprite external and use new_sprite = get_image; allowing me to not have to redownload the game in full.

but is there a way to swap out the exe internal sprite with a new image and it will be saved permanently. next game boot the new sprite will be displayed.
"i assume not seeing how its not raw data but, im no rulling out the possability"
 
Last edited:

Tyg

Member
No, why would it? It would just have to upload the latest sprite updates
And Yes, there are ways to get the next game boot have the new sprites used
Bring your updated sprites file in have a function that checks for latest update version and load the updated sprites.
could have a json file with the added sprite names of files

or better yet instead of sprite_add you could use sprite_replace not sure if it keeps it, but could always save the texture page after an update

Let me check into it more if there is a way to keep them once loaded, maybe keep a current sprite buffer, ill get back to you
ill have to make a little test program, sprite pre_fetch might work as it loads it to the texture page
i mean easiest if you use sprite_save to save it using the actual sprite name in the sprite folder that would make it permanent

I have managed to load and replace the sprite,
im actually outputting the file it's just going to some obscure directory so i just need it to save to the original directory
 
Last edited:

tylerbertz

Member
sprite_replace : it overwrites a previously created sprite index.

this function you brought up, its definition makes me want to try putting a noncreate by code sprite in it and restart the game and see if it holds.
if this was your thoughts then i finaly get it.

but even if this works its not enough to achieve the end goal,
but you said something earlier about updating your game by only downloading the changed files. did you mean with the images internaly added to exe? because if so i want to have that explained
 
Totally feasible to just externalize all resources (not just sprites). Of course as mentioned it does have the downside that they are more easily accessible to prying eyes, but that also has the upside of some very light modding capabilities being present with no extra effort. For sprites exactly I'd suggest loading a whole texture page (and rendering sections of it individually as needed) due to what was already mentioned of externally added sprites being in a separate texture page. I don't have the links right now but I remember seeing several texture packer GML scripts flying around, there's likely even some in the marketplace. Updating the game would then be a matter of updating a catalog of the resources available to the game at runtime and ensuring that the required resources are all present
 
Top