Report bugs or give feedback for CrossCode.

[Suggestion] Pixel Size

no avatar
User

Hao

Posts

2

Joined

Sat Nov 07, 2015 3:46 am

[Suggestion] Pixel Size

by Hao » Sun Feb 12, 2017 2:01 am

For the pixel size option, I noticed that to change it between 1-4, it needs to restart the program each time. I played around with Impact a little and saw the way that weltmeister is able to resize using a cache of the different sizes. I know that that method would take up a lot of memory to store the resized images, but it is possible to at least resize it whenever the button is pressed instead of a restart. Since you resize the canvas to fit the window, it won't affect the way that works. This will just make it so that it will resize all images (and background prerenders if necessary) using the implemented image cache.
Code: Select all
resize: function (scale) {
   ig.system.resize(ig.system.width, ig.system.height, scale);
   //reloads images by size
   for (var i in ig.Image.cache) {
      ig.Image.cache[i].resize(scale);
   }
   //rerenders chunks
   for (var i = 0; i < ig.game.backgroundMaps.length; i++) {
      var bg = ig.game.backgroundMaps[i];
      bg.preRenderedChunks = null;
   }
}

Code: Select all
ig.Image.inject({
   origData: null,
   load: function (loadCallback) {
      this.parent(loadCallback);
      this.origData = this.data;
   },
   resize: function (scale) {
      // Retain the original image when scaling
      this.data = this.origData;
         if (scale > 1) {
         // Nearest neighbor when zooming in
         this.parent(scale);
      } else {
         // Otherwise blur
         var scaled = ig.$new('canvas');
         scaled.width = Math.ceil(this.width * scale);
         scaled.height = Math.ceil(this.height * scale);
         var scaledCtx = scaled.getContext('2d');
         scaledCtx.drawImage(this.data, 0, 0, this.width, this.height, 0, 0, scaled.width, scaled.height);
         this.data = scaled;
      }
   }
});

I don't know, just a suggestion so that you can see the immediate effects of pixel size. Great game tho!

Who is online

Users browsing this forum: Google [Bot] and 4 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign
cron