How SpritePackedManager works or maybe is not working at all

Why do yall need me to look at it? Its not my code… and I posted what was wrong with it already.

Its literally an empty class that does nothing. I have no association with this lol. <3

Buuuuuuut, if everyone really really needs this to happen Ill bite the bullet and take responsibility on making this thing actually do something. Was kind of hoping @pavul was going to finish what he was doing to make the normal Sprite manager work with an atlas.json then we where going to migrate that to the manager class.

So sorry buddy! I think this is my fault. For some reasons I’m associating you with the Sprite Map and thus this file!

Haha its all good, I was mainly just messing with people. XD

that eneAtlas.json has the format is in documentation…

on the other hand, playAnimation iterates all the sprites defined in SpritePackedManager instead the frames defined

do you need me to do something? can you be more specific

No you are good brother, just seeing if you were able to make them do what you needed. If you had I was going to reference your code and make the packed manager work like whatever you ended up doing.

i implemented a workaround i could not use SpritePackedManager features, i hope you can address that to fix it in the near future, i will gladly test it, btw my workaround was to implement particles for the explosions, but i think it would be better just changing the animation.

i know babylon is for 3d, but i am trying to make a 2D simple scrolling shooter to learn the library myself and maybe create a tutorial for 2D games using babylon.js

I looked at this again and understand more about the SpritePackedManager now, and I don’t think it is intended to support the kind of animations you want.

Maybe try the SpriteMap class?

Here’s a playground example…
https://playground.babylonjs.com/#YCY2IL#2337.

It uses multiple SpriteMap instances that reference the same image and atlas json. You can’t make the SpriteMap width zero to make it disappear so it can be replaced by the explosion, but you can move it off the screen by setting its position to a very large number (Infinity in the example).

i’ll study that code later, thanks a lot, will reply if i have doubts or something else…

1 Like

I would not recommend using the spriteMap for this. It only support square sprites really.

but if you where going to use it, you do not need to have two for the one sprite. You could even use layers to make sure the “enemy” sticks around for a second.

that is what i read;

Since the plane is split into a grid of tiles of the same size the cells of the packed spritesheet should be of the same size.

so that not really works when you have an atlas like this, with different animations or sprites of different size:

I think SpritePackedManager approach should work if instead of iterate thru the sprites iterates over the frames of each individual animation.

after a while i could found a workaround:
@Deltakosh @docEdub @Pryme8

if you would like to play different animations from an atlas image like i have, you will be forced to add every frame as i did with enebullet_f1 and enebullet_f2, it does not matter if you defines the frames inside the object cause will be ignored, i think that is confusing (but at the end i think i am the only that is trying to make a 2D game with a 3d tool ).

however i found something curious as well in this example:

that is how SpritePackedManager treats the image atlas, like a single big sprite with a lot of frames ( for that big sprite ).
in the code SpritePackedManager is a wrapper for SpriteManager, it just set packed to true and pass it JSON file data, nothing more. ( i think someboyd mentioned that time ago above ), but due all the properties are private is not possible to set them with new values cause we don’t have setters, i am refering to:

  private _cellData: any;
    /** Array of sprite names from JSON sprite data file */
    private _spriteMap: Array<string>;
    /** True when packed cell data from JSON file is ready*/
    private _packedAndReady: boolean = false;
    private _textureContent: Nullable<Uint8Array>;
    private _onDisposeObserver: Nullable<Observer<SpriteManager>>;
    private _fromPacked: boolean;

from spriteManager.ts

that’s it to me guys, i hope this can be of some help. thanks in advance.

2 Likes