문제

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