質問

Is it possible to dynamically change the Atlas Region used by a particle emitter?

I've tried...

effect.getEmitters().get(0).setImagePath("[someAtlasRegionName]");

...but it continues to use the original region the effect was loaded with.

There appears to be a .setSprite(Sprite) method but it doesn't work with TextureAtlas.

Thanks.

役に立ちましたか?

解決

Editing the Sprite's fields to set it to the TextureRegion works (Sprite extends TextureRegion, so it has all the relevant fields):

Sprite s = effect.getEmitters().get(0).getSprite();
s.setTexture(vessel.getTexture());
s.setU (someAtlasRegion.getU());
s.setU2(someAtlasRegion.getU2());
s.setV (someAtlasRegion.getV());
s.setV2(someAtlasRegion.getV2());
effect.getEmitters.get(0).setImagePath(someRegionName);

Edit: I don't know if ParticleEmitter.setImagePath() matters or not, but I'd include that as well just in case - it definitely won't hurt. So I added that as well.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top