Pass texture inside texture atlas for ParticleEmmitter

I have a voxel word, and use a texture atlas 16×16 for the blocks, when a player breaks a block, use a ParticleEmmitter to release particles trying to use the texture block which was broken (which is in a atlas) but when passing the texture atlas to ParticleEmmitter, the result of course does not occur as expected, the particles are the atlas whole, not being can specify which local x y within the texture atlas use to ParticleEmmitter.

My “TextureAtlas” is a image, not TextureAtlas class.

From the manual (F1 in SDK)

Material flash_mat = new Material(
    assetManager, "Common/MatDefs/Misc/Particle.j3md");
flash_mat.setTexture("Texture",
    assetManager.loadTexture("Effects/Explosion/flash.png"));
flash.setMaterial(flash_mat);
flash.setImagesX(2); // columns
flash.setImagesY(2); // rows
flash.setSelectRandomImage(true);

But I think the only way to make the ParticleEmitter always pick one image from the atlas is to fork the code. My memory may be fuzzy there, though. You could always look at it.

A solution that would work would keep the image of each block for example “wood.png” and “stone.png” but it would lose the sense of atlasing and leave the code and unorganized assets.

Or you could take my suggestion. Unless you are afraid of the code… then yours works.

@pspeed oh, I understood what did you mean, the translator did not work very well, I thought you said you wanted to see the code of my Emmitter, not that it was for me fork Emmitter code, sorry.

Yeah, Normen’s code showed you how to setup an atlas in the emitter. It will pick a random image from the atlas, though.

If you make your own ParticleEmitter based on that code, it should be pretty easy to just force all p.imageIndex to be your own atlas index.

Exactly, I have studied the source of ParticleEmitter and will work! Thank you for help!