Is it possible to save multiple snapshots of a drawing canvas?

1 favourites
  • 15 posts
From the Asset Store
You need this package if you want to program a Street Fighter or battle game.
  • The drawing canvas has an action to save a snapshot, and there is another action which load back the saved snapshot, it there a way to have multiple snapshots of the canvas and load them back in with a tag or index? I tried saving the drawing canvas json and then loading from it but that does not hold image information,

  • Yes, you can add "DrawingCanvas Save Image" action, and then in "DrawingCanvas on saved image" event use DrawingCanvas.SavedImageURL expression - it will contain your image data. You can do whatever you want with this data - load to sprite, another canvas, save to local storage etc.

  • yah after saving the image, it does not seem there is a way to get it back into the canvas. there is no load image action. and it seems SavedImageURL contains a url to the actual image, there is no way to read the actual image data back into the canvas from the url

  • You are right, there seems to be no direct way to load image to canvas. But you can use a sprite - load SavedImageURL string into the sprite. Then paste the sprite onto canvas. I tested this and it works.

  • It's all good, I created a simple addon that does what i need. I'll release it when i get it ready. thanks =)

  • Hello, do you know how to save an image I just loaded, because when I save my game, the loaded images are not saved:(

    In my game, the user can load an image and put it on the scene, but when he saves the game, and reloads, the image is no longer there:(

  • it depends where you are getting your image from? for my particular case it was not an external image, the image would be drawn using the drawing canvas action, then i would use the snapshot action. then i had a custom plugin that would take that the snapshot data and serialize it. then i can store the data in local storage. my custom plugin also could load back that serialized data and load it back to the snapshot. i have not used the new binary plugin not sure if that might help store the data some how?

  • I get my image with a file selector with a URL, it's to make a game or the player create his game, so he has to load images and sounds and other things, he create his game this way....

    Example: He loads an image of his choice, to put it on the stage, with a sprite for this purpose, to create this scene, he creates his scenery with images that he must import, sounds, etc...

    But it has to be persistent, I create a game to create a game ^^

    drive.google.com/open

    Try the project, put images on the stage, save the game (Watch at scene 3), change the images of the scenes, reload the game, the images are not loaded.

  • Dayvid86 okay here is a simple example on how to persist the sprite data using local storage, binary plugin, and ajax... that binary plugin is really awesome btw

    https://drive.google.com/open?id=19VdUGgsPLb3CaogYuylCSwCgqb03D-2C

    hope this helps,

  • piranha305 Nice demo, thanks! Do you know how to get binary data (Base64) from an existing sprite, or from drawing canvas?

  • dop2000 here is a simple sample of getting base64 from drawing canvas

    https://drive.google.com/open?id=1ynDDcouZA7dbulP9jTSkCUgWAlh4MOex

    for a sprite it's a bit tricky since the sprite does not expose it's image data, you would have to paste it to the drawing canvas and follow a similar pattern to get the base64. the only plugin i know that gets the base64 string is the binary plugin. so if you can somehow get the image in there you could request the base64 representation of the image.

  • Oh, so you can use AJAX to extract image data from canvas. Good to know, thanks!

  • so right now you can only load an image from a sprite, if there was an expression to save the image as base64, it would make it a much nicer experience to transport data between all these plugins. I am just not sure how that would work, it would have to save all the animation data as well

  • I posted a suggestion to include this into Binary Data plugin. You can leave a comment if you have something to add or maybe have a better idea:

    construct3.ideas.aha.io/ideas/C3-I-762

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • piranha305 Thank you very much for your example !

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