• Runtimes
  • AS3 How to load multi png texture ?

Related Discussions
...

Hi,

We have added a couple more images in our main characters animation and the we now have 2 exported skeleton.png files(skeleton.png + skeleton2.png).

Our problem is that we do not now how to load both png files into AS3. What we are currently doing with the original 1 skeleton.png file is the below:

[Embed(source = "skeleton.atlas", mimeType = "application/octet-stream")]
static public const SpineAtlas:Class;
	
[Embed(source = "skeleton.png")]
static public const SpineAtlasTexture:Class;

var atlas:Atlas = new Atlas(new SpineAtlas(), new SingleTextureLoader(new SpineAtlasTexture()));

Is there something like MultiTextureLoader??? instead of SingleTextureLoader

Thanks in advance

I've committed a new texture loader for Flash and Starling that can handle a multiple page atlas. SingleTextureLoader is gone but the new FlashTextureLoader or StarlingTextureLoader can be used exactly the same way. Alternatively, you can specify an object that maps the image path from your Spine data to the Bitmap or BitmapData:

var atlas:Atlas = new Atlas(new SpineboyAtlas(), new FlashTextureLoader(new SpineboyAtlasTexture()));

// OR

var atlas:Atlas = new Atlas(new SpineboyAtlas(), new FlashTextureLoader({
    "spineboy.png": new SpineboyAtlasTexture()
}));

Obviously you can specify multiple bitmaps when passing an object.

Thanks Nate,

We have performed the following , as per your reply

var atlas:Atlas=new Atlas(new SpineAtlas(), new FlashTextureLoader({
"skeleton.png": new SpineAtlasTexture(),"skeleton2.png": new SpineAtlasTexture2() }))

and we have the following problem. The idle animations of our characters are played backwards. Attacks and walking animations function normally. Can you understand why this has happened??

Thank you...

Ehm, no idea really. AnimationState doesn't support playing backward. You sure it's not something else?

Yes i am sure ...i played the idle animation backwards in spine , side by side with the swf, and it was the same. I will perform some more tests and revert, if i understand something extra

Thanks

Hi Nate,

Actually you were right, sorry my mistake, the animation is not played backwards.

Correct idle animation: The character performs a small jump(up on y axis) while his toes are pointing to the ground
Wrong Idle animation(after the new runtime) : the character moves up on y axis while his toes are parallel to the ground

It is as if , although the frames are played normally...the movement on y axis has been reversed.

Does this make any sense?

Ok, though that doesn't give any clue as to what the problem might be. 🙁 Maybe something to do with attachment changes? I'm afraid you'll need to debug it further or show a simple example of the problem.

So far I have 2 characters in the game! A spartan and a Persian! We have not changed anything on the Persian( same json, same atlas and same skeleton.png, only one) and he has the same problem as the spartan, only in the idle animation after the runtime change. I think that it does not affect other animations since they do not have y axis movement! We reloaded the original spartan json withe 1 skeleton.png and the problem is still there! I will try to send you a small video from the animations! If you need something extra pls tell me...
Thanks

Hi Nate,

I tried to upload the videos but i could not, so i created 2 screenshots from the Persian Character(Idle animation) , on which we did not make any change at all, before and after the runtime update. Hope it helps you to understand what is causing the problem.

Doesn't help, sorry. Can you edit the example that comes with the runtime to show the problem using your skeleton, then email the code, project file, images, and atlas to contact@esotericsoftware.com?

Hi Nate,

Yesterday i forwarded all requested files, as per your last post.

Thank you

Got it, thanks. Seems I had the root bone translation incorrect for most of the runtimes. :o Not sure why. I fixed it and tested it on multiple runtimes, should work now!

Thanks Nate,

I will revert only in case something is wrong.

Great Support :yes: