Discussion Is this possible in Game Maker Studio 2

Discussion in 'GameMaker Studio 2 Community Tech Support' started by Thamanator, Oct 1, 2019.

  1. Thamanator

    Thamanator Member

    Joined:
    Oct 1, 2019
    Posts:
    10
    Would it be possible to allow a user to modify the sprite that a game I make uses, to represent them, better? I am of course talking about the end result game. Are files accessible to the end user, or does the whole game compile to some form of compressed files that are uneditable to the end user?

    If it is unaccessable to them, is it possible to code it, so that it uses a png or pngs that they have access to?
     
  2. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    4,535
    Include the sprite(s) you want to be accesible to the players as an "Included File" and it will be inside a regular folder when you export your game.
    They can ten edit this using a regular paint program and you would then load this into your game using sprite_add() and it will then be used like a regular sprite.

    Be aware that sprite_add() creates a new texture page for each sprite, although with just a few sprites this shouldn't be an issue.
     
    ParodyKnaveBob and Mike like this.
  3. kroart

    kroart Member

    Joined:
    Jun 16, 2018
    Posts:
    14
    GameMaker packs all sprites into it's data.win file (at least on Windown and Android). In any case all sprites are packed into game's archive and not accessible for users.
     
  4. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    4,535
    No, as I said in my previous post - if you put sprites (or any other files) into Included Files they are exported as regular image files along with the executable and data.win when you compile.

    You can then load them into the game using sprite_add(), which means players would be able to edit them, save them and have them loaded into the game.
     
    Last edited: Oct 2, 2019
    Amon likes this.
  5. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    740
    Note that simply adding them as included files is not enough if you want the players to edit them, since as far as I know included files are overwritten with the original ones every time the game is run (at least on desktop platforms, unless something has been changed recently in that regard). Ideally you should copy them to the writable sandbox directory and point the player to that location.


    edit: not the case anymore
     
    Last edited: Oct 2, 2019
  6. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    4,535
    No, you can freely edit images from Included Files when exported with the exe and the game will load the new edited images without any issue.
    Unless you mean when "running" from the IDE rather then when exporting as a final exe?

    I just tested this and the png file from Included Files was exported along with the exe and data.win.
    I then edited that png, saved it, and re-ran the exe and the edited sprite loaded and worked fine.

    This is a simple use case just to show the functionality of course, and in real world use you'd want to run checks on the edited image to make sure it was within acceptable width/height, reset any sprite origins and/or masks etc based on the requirements of your game.

    I'm talking about Windows here too, not sure when on mobile as I have not tested it so it may well work differently there.
     
    Last edited: Oct 2, 2019
    Catan likes this.
  7. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    740
    Weird, I tested this specific behavior some time ago and had different results, but you are right @rIKmAN , both on windows and mac I don't see this anymore (or maybe I was running the wrong tests from the beginning).
     
    rIKmAN likes this.
  8. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    4,535
    Were you exporting to a final exe, or running from the IDE?

    It's make sense that it wouldn't work running from the IDE as it would be creating / exporting new files each time you ran it, but for exported executables it's been like this for at least 18mths or so as I used to use this method when making changes to Spine skeletons so that I didn't have to keep re-importing the json files into the IDE each time I made changes to it in Spine and exported new json.

    It meant I could just export from Spine into the game folder and run the exe file to have it use the new skeleton json loaded in via sprite_add().

    I'd assume it would be the same for regular sprites too, but again I can only confirm this for Windows.
     
  9. Mike

    Mike nobody important GMC Elder

    Joined:
    Apr 12, 2016
    Posts:
    2,367
    Worth remembering that if you change the root files and you release using Steam or something, any update will wipe the files.

    If you put them in the "save" location, then these will be loaded instead of the included file version. This was to allow changing of the root files without corrupting the base install - and because you obviously couldn't save to an install folder every time.

    by default, the game saves to %localappdata%\GameName, although you can change this in the options.
     
    rIKmAN, Catan and ParodyKnaveBob like this.
  10. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    740
    Regardless of the assumptions above about included files being overwritten, it is probably a good idea to copy those to the save location anyways if you want the user to edit them manually, so you always keep a copy of the original. I'm thinking about an accidental deletion of a file or corruption for example, but even a feature to "reset" the changes made by the player.
     
    rIKmAN likes this.
  11. Thamanator

    Thamanator Member

    Joined:
    Oct 1, 2019
    Posts:
    10
    Thank you all! Especially rIKmAN! You went above and beyond, by testing it for me!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice