Can libgdx Particle Effects use texture regions? -
i have of images libgdx project in single texture.
i'm add nice particle effects, documentation implies each type of emitter requires separate graphics file particle.
is true? or, there way of specifying region of texture used particle image, may still keep images in single file?
yes can but need have texture inside of textureatlas
. take @ this article it.
here example use textureatlas:
m_effect = new particleeffect(); m_effect.load(gdx.files.internal("particle/effects/lightning.p"), this.getatlas());
or in 2 steps:
m_effect.loademitters(gdx.files.internal("particle/effects/lightning.p")); m_effect.loademitterimages(this.getatlas());
here whatt loademitterimage
does:
public void loademitterimages (textureatlas atlas) { (int = 0, n = emitters.size; < n; i++) { particleemitter emitter = emitters.get(i); string imagepath = emitter.getimagepath(); if (imagepath == null) continue; string imagename = new file(imagepath.replace('\\', '/')).getname(); int lastdotindex = imagename.lastindexof('.'); if (lastdotindex != -1) imagename = imagename.substring(0, lastdotindex); sprite sprite = atlas.createsprite(imagename); /// <---- here creates sprite textureregion if (sprite == null) throw new illegalargumentexception("spritesheet missing image: " + imagename); emitter.setsprite(sprite); } }
Comments
Post a Comment