How do I let the player save an image in their save file using LocalStorage?

Not favoritedFavorited Favorited 0 favourites
  • 4 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hello Construct Forums!

    I'm currently working on a racing game and I want to add a "custom machines" feature where players can upload their own PNG images to the game and use them as playable machines to race as. I've already implemented the code that allows the PNGs to be used as the machine, and you're able to race as it and stuff.

    But I want to know how to keep this image in the game's save data, so that way you don't have to upload it every single time you play. How would I go about doing this? I tried saving the image URL (FileChooser.FileURLAt(0)) to the LocalStorage, which works but when I tried to load the image URL again after restarting the project nothing would happen, and I think it has something to do with the fact that the URL starts with "blob:" meaning it only exists in the browser's short term memory. How do I get this URL to properly be saved in the browser's long term memory?

    Sorry if this is complicated, I can provide more information such as screenshots if needed.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • In short, you can load a URL in to a Binary Data object with the AJAX object by using 'Set response binary' just before making the request. Then you can write that Binary Data to storage using the Local Storage 'Set binary item' action. You can load it again with 'Get binary item' and if you need a URL again, use the GetURL expression of the Binary Data object.

  • In short, you can load a URL in to a Binary Data object with the AJAX object by using 'Set response binary' just before making the request. Then you can write that Binary Data to storage using the Local Storage 'Set binary item' action. You can load it again with 'Get binary item' and if you need a URL again, use the GetURL expression of the Binary Data object.

    Ok thank you! I made a test project and I'm pretty sure I got it working now, thank you so much Ashley!

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)