(alternative found) How do I reduce DrawingCanvas size before saving to LocalStorage?

0 favourites
  • 3 posts
From the Asset Store
Template for an alternative to falling shapes, fully documented in comments and video
  • I'm making a sidescroller and I'm using the DrawingCanvas as part of a levelMap feature. Basically, the DrawingCanvas is the size of the layout, overlays the layout, is invisible, and is initially all black. As the main character moves, the area around the mc is 'erased' in the DrawingCanvas. When the player opens the levelMap, they'll see the entire layout zoomed out, with the DrawingCanvas (now visible) on top. So they'll only see the parts of the layout where the mc has been, because those areas have been erased in the DrawingCanvas.

    This works great, but I need to save the DrawingCanvas for savegames. Because my layout is so large - 22k x 11k pixels - saving the DrawingCanvas to LocalStorage takes 5+ seconds. I'd like to reduce that savetime. FYI I'm using this save approach, Thanks dop2000 ! - construct.net/en/forum/construct-3/how-do-i-8/save-current-state-163694

    Since I don't need a very high-quality image in the DrawingCanvas, is it possible to downscale the DrawingCanvas to maybe 10% of the size, and then save it to LocalStorage? Of course this means I would need to upscale it when reloading the savegame? If so, how would I do that? ChatGPT gave some suggestions but she's hallucinating somewhat and sending me down ratholes.

    Any other options? Is there a way to start with a smaller DrawingCanvas, and clear areas of it based on a layoutSize-to-DrawingCanvasSize calculation of some sort? I would then have to expand/resize the DrawingCanvas when viewing the levelMap...

    Or are there other ways to design such a levelMap that doesn't use a DrawingCanvas, maybe some other object type?

    Thanks

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So I found an alternative, and that's to use a TileMap instead of a DrawingCanvas. I had a lot of issues with DrawingCanvas and savegames, LocalStorage, restarting layouts, etc. So far TileMap has been a good alternative with none of the same issues. Thanks to anyone who looked at this.

  • 22k x 11k pixels

    That's almost 1GB, if my math is correct. You definitely should avoid writing so much data. On old devices with HDD this could take minutes to save!

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