[SOLVED] Spine2D Extension - Scaling for multiple devices?

Hey All,

(The original post is in 'Extensions which I believe is not the correct location for this question, so I shall post it here instead).

I'm currently using the ByRobin Spine2D extension, and am curious to know how to apply scaling for each mobile device. In the past I have used a 'Freeform' block for my images (image_API) to find any image with the file name ".....@1x.png", "....@2x.png", "...@3x.png", and so on based on the device used, which works perfectly! But I'm curious to know if there is a way to do this for Spine Assets as well. I have attached a few screenshots on what I have currently done for my spine assets. But if there is a way to use the correct scale for each mobile device, that would be awesome!

Cheers in advance!


« Last Edit: February 17, 2019, 04:43:58 pm by JuicyBeetleGames »

This is the code for the Image API script to know which image to use based on the device scale...


package scripts;

import com.stencyl.Engine;

import nme.display.BitmapData;
import nme.geom.Matrix;

class ImageUtil
   public static function scaledImg(name:String):BitmapData
      if(Engine.IMG_BASE == "1x")
         return nme.Assets.getBitmapData("assets/data/ImageAPI/"+ name +".png");
         var toReturn = nme.Assets.getBitmapData("assets/data/ImageAPI/"+ name + "@" + Engine.IMG_BASE + ".png");
         if(toReturn == null)
            toReturn = scaleBitmap(nme.Assets.getBitmapData("assets/data/ImageAPI/"+ name +".png"), Engine.SCALE);
         return toReturn;

   public static function scaleBitmap(src:BitmapData, s:Float):BitmapData
      var newImg:BitmapData = new BitmapData(Std.int(src.width * s), Std.int(src.height * s), true, 0);
      var matrix:Matrix = new Matrix();
      matrix.scale(s, s);
      newImg.draw(src, matrix);
      return newImg;


If there is something like this, but for Spine2D, I would love to know how to implement it :)