rstarks

  • 5 juin 2014
  • Inscrit 23 janv. 2014
  • Cross-posting this from the off-topic forum because I think it is potentially more on-topic than not and might be useful for some:

    http://animagnum.com/projects/spine/SpineScale.zip

    I made a quick and dirty tool that will adjust an exported JSON file in case you need to scale an entire animation to work with different sized assets. The swf will require some form of Flash Player in order to run as it currently does not work when run through a browser. The tool looks for a file named skeleton.json in the same directory as the swf. You can easily rename a file and then change it back when you're done. Enter in the scale value you want to multiply the object by and then click the scale button. You will be prompted to save a new file so the original remains untouched.

    Here's an example of how it works:

    I created some assets and an animation at one scale (1x) but needed to resize the animation for 2x. First I made 2x assets in Photoshop and then replaced the original assets in my /images/ folder. Then I used my tool to modify the JSON file and used a scale value of 2. This process multiplied all of the relevant values by 2 and then saved a copy of the original JSON. Back in Spine I clicked "Import Data..." and selected my modified JSON file. Then I pointed it to the directory with the resized images. This resulted in doubling the size of the animation I had previously been using.

  • http://animagnum.com/projects/spine/SpineScale.zip

    I made a quick and dirty tool that will adjust an exported JSON file in case you need to scale an entire animation to work with different sized assets. The swf will require some form of Flash Player in order to run as it currently does not work when run through a browser. The tool looks for a file named skeleton.json in the same directory as the swf. You can easily rename a file and then change it back when you're done. Enter in the scale value you want to multiply the object by and then click the scale button. You will be prompted to save a new file so the original remains untouched.

    Here's an example of how it works:

    I created some assets and an animation at one scale (1x) but needed to resize the animation for 2x. First I made 2x assets in Photoshop and then replaced the original assets in my /images/ folder. Then I used my tool to modify the JSON file and used a scale value of 2. This process multiplied all of the relevant values by 2 and then saved a copy of the original JSON. Back in Spine I clicked "Import Data..." and selected my modified JSON file. Then I pointed it to the directory with the resized images. This resulted in doubling the size of the animation I had previously been using.

  • Sorry for not being specific, I'm actually a UI designer/part-time coder trying to help an artist with some of his work. I'm a little lost. As far as I can understand, we'd like to be able to work with the character at a larger size and then export a smaller version of the same character with its animations scaled down properly. Basically I was asked to modify the values of the .json file based on some of the details in this thread.

    {"bones":[{"name":"root","x":0.96]},{"name":"bone","parent":"root","x":38.81,"y":278.66}

    Based on your previous post I took the original, working .json file and changed the x value above. Notice there isn't a Y value


    which sounds like it might be another problem, or perhaps I changed the wrong thing. The x value was 1.92 but I changed it to 0.96 and then we loaded assets into Spine that were 50% of the original size. In any case, thanks for taking time to respond to this, I appreciate the help.

  • We were able to change the X scale value of the root bone in the .json file and it seemed to work. The Y scale was zero. It appears that the order of the .json file as it is generated from Spine is precise but the script I mentioned in my previous reply loses this order. I would have thought that the ordering of the file didn't matter but apparently it does. Is there an ETA on when a scaling feature like DanielEgan requested could be implemented? Thanks.

  • I wrote an AS3 script to scale the appropriate values within the skeleton JSON file and we're having a little trouble with it. It almost works but some of the animations get messed up. I'm scaling anything with the key value of x, y, width, height, or length as long as it isn't within rotate or scale. Here's the specific logic I'm using in case it would help:

    //function to recursively check a decoded JSON object
    function processParameters(jsonObject:Object):void {
    	for(var key:String in jsonObject) {
    		var n:Number = Number(jsonObject[key]);
    		if (isNaN(n)) {
    			if (key != "rotate" && key != "scale") {
    				processParameters(jsonObject[key]);
    			}
    		} else {
    			if (key == "x" || key == "y" || key == "width" || key == "height" || key == "length") {
    				jsonObject[key] = n * SCALE_VALUE;
    			}
    		}
    	}
    }

    We've scaled the images by the same amount. I was wondering if anyone else had better luck with this process.