• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Android (Android) Load sprite from gallery

Z

Ziphold

Guest
I'm making a roulette-style game where you can add custom images and set percentages that the images will be chosen. I was wondering if it is possible to make a button that, when pressed load all sprites from gallery and makes it possible for user to choose an image and add it in.
In advance-thank you.
 

PNelly

Member
docs.yoyogames.com >> Contents >> Reference >> File Handling >> File System Limits

docs.yoyogames.com >> Contents >> Reference >> Game Assets >> Sprites/BackGrounds

Those are the constraints of GameMaker's file system and the available functions to add resources at runtime. Be aware that image resources loaded at runtime are allocated their own texture page and will have detrimental performance affects (after a couple of images) unless you do some pretty intensive custom rebuilds of texture pages using surfaces.
 
Z

Ziphold

Guest
docs.yoyogames.com >> Contents >> Reference >> File Handling >> File System Limits

docs.yoyogames.com >> Contents >> Reference >> Game Assets >> Sprites/BackGrounds

Those are the constraints of GameMaker's file system and the available functions to add resources at runtime. Be aware that image resources loaded at runtime are allocated their own texture page and will have detrimental performance affects (after a couple of images) unless you do some pretty intensive custom rebuilds of texture pages using surfaces.
Yes, I did explore those pages already. However, my answer does not hide there, im pretty sure. My question is if there is a specific extension to do it, perhaps a funtion that would open a window to choose a photo from.
 

PNelly

Member
I assure you that some careful reading and exploration will give you the answer you're looking for

My question is if there is a specific extension to do it, perhaps a funtion that would open a window to choose a photo from.
There are basically two directions you can go. You could use get_open_filename(), which opens a dialogue window and allows the user to choose a file from anywhere the file system. However it's pretty gross looking and it's windows only. Additionally I believe you can only grab one file at a time.

Your other option would be to use the file system functions to explore the working directory and see what, if any, image files are present. You'd then build a custom system to produce an in-game "window" for the user to navigate and select the files they want. Or you could iterate through them using file_find_first() and file_find_next() and load them automatically.

Either way you're constrained by GM being Sandboxed. With the exception of get_open_filename() on the windows platform, the image files have to be located either in the game bundle or in the save area. Getting your custom images into one of those spots means either bundling them inside of "included files" or having the user manually move image files into the working directory where GameMaker can fine them.
 
Z

Ziphold

Guest
I assure you that some careful reading and exploration will give you the answer you're looking for



There are basically two directions you can go. You could use get_open_filename(), which opens a dialogue window and allows the user to choose a file from anywhere the file system. However it's pretty gross looking and it's windows only. Additionally I believe you can only grab one file at a time.

Your other option would be to use the file system functions to explore the working directory and see what, if any, image files are present. You'd then build a custom system to produce an in-game "window" for the user to navigate and select the files they want. Or you could iterate through them using file_find_first() and file_find_next() and load them automatically.

Either way you're constrained by GM being Sandboxed. With the exception of get_open_filename() on the windows platform, the image files have to be located either in the game bundle or in the save area. Getting your custom images into one of those spots means either bundling them inside of "included files" or having the user manually move image files into the working directory where GameMaker can fine them.
Thank you for the fast answer. Looks like im being constrained, as you are saying. Therefore it seems like I will have to cancel my project. Anyways, thanks for the help!
 
Top