Report bugs or give feedback for CrossCode.

[Suggestion] Pixel Size

no avatar





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) {
   //rerenders chunks
   for (var i = 0; i <; i++) {
      var bg =[i];
      bg.preRenderedChunks = null;

Code: Select all
   origData: null,
   load: function (loadCallback) {
      this.origData =;
   resize: function (scale) {
      // Retain the original image when scaling = this.origData;
         if (scale > 1) {
         // Nearest neighbor when zooming in
      } 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(, 0, 0, this.width, this.height, 0, 0, scaled.width, scaled.height); = scaled;

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







Wed Jan 14, 2015 4:35 pm

Re: [Suggestion] Pixel Size

by lachsen » Sat Mar 18, 2017 8:50 am

Hey there,

yeah impact.js does that, but that was because back then canvas didn't have any option to draw sharp pixels. This was fortunately added, which is why we don't scale images anymore like this - and I'd never go back to this, since it easily means you have 4x, 9x or 16x the memory consumption you'd normally have for images - and images are the majority of what consumes memory already.

And even if we did this, you'd still need to do a lot of work to make the pixelsize changeable without restarting the game. In general this makes the feature much harder to implement and I don't really think it's worth the effort.

Who is online

Users browsing this forum: No registered users and 1 guest

Powered by phpBB ® | phpBB3 Style by KomiDesign