gpt4 book ai didi

json - 来自 TexturePacker 的 EaselJS Spritesheet

转载 作者:行者123 更新时间:2023-12-01 05:44:02 24 4
gpt4 key购买 nike

如何从 TexturePacker 为 EaselJS 创建正确的 spritesheet 导出?导出后我得到这样的东西......

{
"images": ["textures.png"],
"frames": [
[818, 44, 42, 42],
[818, 1, 42, 42],
[775, 87, 42, 42],
[775, 44, 42, 42],
[775, 1, 42, 42],
[732, 87, 42, 42],
[732, 44, 42, 42],
[732, 1, 42, 42],
[689, 87, 42, 42],
[689, 44, 42, 42]
],
"animations": {
"load_indicator_01":[0],
"load_indicator_02":[1],
"load_indicator_03":[2],
"load_indicator_04":[3],
"load_indicator_05":[4],
"load_indicator_06":[5],
"load_indicator_07":[6],
"load_indicator_08":[7],
"load_indicator_09":[8],
"load_indicator_10":[9]
},
"texturepacker": [
"SmartUpdateHash: $TexturePacker:SmartUpdate:9148c4d9cc1b277627212fb0bffcda4d:fabda013c371507b8fb93d52f15735a0:205920eec6ac5ad8b6794732cd49ae1d$",
"Created with TexturePacker (http://www.texturepacker.com) for EaselJS"
]
}

每一帧都被定义为一个毫无意义的动画。这个导出商只是一个笑话,还是我如何才能正确地导出 EaselJS?有什么技巧吗?

最佳答案

基本上是 easeljs 要求 spritesheet 的格式你会做下一个:

$.getJSON("sprites.json", function(json) {
spriteSheet = new createjs.SpriteSheet(json);
});

并为每一帧创建一个变量,在你的例子中:

var load_indicator_01 = new createjs.Sprite(spriteSheet, "load_indicator_01");

为了自动化,我制作了这个片段:

var spriteSheet;
var sprites = {}
$.getJSON("sprites.json", function(json) {
spriteSheet = new createjs.SpriteSheet(json);
for(var sprite in json.animations){
sprites[sprite] = new createjs.Sprite(spriteSheet, sprite);
}
});

`

关于json - 来自 TexturePacker 的 EaselJS Spritesheet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21778102/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com