How do I get my game to remember an image change?

  • In my game the user is able to change the look of a sprite by uploading an image using the filechooser object.

    I was wondering if there was a way of saving this change so that the next time the user runs the game the sprite keeps it's new appearance?

    I've tried the save game action but that doesn't seem to work?

    Many thanks,

    Matt

  • Still struggling with this, does anyone have any ideas?

  • I think you need to use local storage, Matt. It should be relatively easy to do. Let us know how it goes! Btw, are you from Texas? I have a friend names Matt Daly. :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the suggestion, I have made an attempt at getting this to work using local storage but am still having no luck

    Please see this download link for my attempt:

    https://www.dropbox.com/s/a8zexej38kcdss7/Permanent_image_change.c3p?dl=0

    If anyone would be willing to take a look and point me in the right direction I'd really appreciate it!

    adelwich No i'm not from Texas, I'm from Manchester UK. Your friend must be an impostor!

  • :)

    It has been a while since I poked around with local storage, but I remember that you have to check to see if locally stored variables exist before you try to read and write those variables.

    This tutorial was very helpful:

    javajdk.net/tutorial/localstorage-in-construct-2

    This event sheet diagram is from that article:

    As the author of that tutorial explains:

    "The key to understanding this event sheet is that Construct 2 LocalStorage is asynchronous. Every LocalStorage action has a matching event that you can use as a condition. Every request to LocalStorage generates an event rather than giving you an answer right away. Remember LocalStorage always says, “I’ll get back to you.” It never gives you something exactly when you ask for it, though it is typically so fast your users won’t notice the difference."

    I struggled with other local storage tutorials but something about this person's explanations made sense to me.

    Best of luck. Please let us know if you solve the problem, Matt from Manchester!

  • Thanks again adelwich for taking the time to help with this...

    I've worked through the tutorial and feel I have a better understanding of local storage now. Thing is, am I right in thinking that local storage can only store numbers or strings? Will it work for storing an image file too? That's what I need...

    Matt

  • Sorry to keep banging on about this but I still haven't found a solution :(

    Over on the Construct 2 forum (where I wrongly posted this topic to begin with) dop2000 kindly suggested:

    You can use two Pode's addons - ExtractImage and InjectImage, download them here:

    github.com/Pseudopode/construct2_plugins_behaviors

    Extract image from sprite as Base64 string, save it to local storage. Next time you need it - get it from local storage and inject into the sprite."

    Is there a similar plugin that would work for Construct 3 that anyone could recommend?

    Many thanks,

    Matt

  • Can I bump this topic again?

    To clarify, I want the user to be able to change the appearance of a sprite by uploading an image file saved on their device and for this change to be saved so that the next time they play the game, the image change is retained.

    Many thanks,

    Matt

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