Skip to content

Commit

Permalink
Merge pull request #2023 from obigu/fix2
Browse files Browse the repository at this point in the history
Adds back previous ParticleEffect API methods and minor convention chang...
  • Loading branch information
badlogic committed Jun 26, 2014
2 parents 2cc613f + a1cec6c commit dc4bbca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Expand Up @@ -59,8 +59,8 @@ public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file,
public static class ParticleEffectParameter extends AssetLoaderParameters<ParticleEffect> {
/** Atlas file name. */
public String atlasFile;
/** Prefix to be added to the image names **/
public String atlasPrefix = "";
/** Optional prefix to image names **/
public String atlasPrefix;
/** Image directory. */
public FileHandle imagesDir;
}
Expand Down
10 changes: 9 additions & 1 deletion gdx/src/com/badlogic/gdx/graphics/g2d/ParticleEffect.java
Expand Up @@ -139,6 +139,10 @@ public void load (FileHandle effectFile, FileHandle imagesDir) {
loadEmitterImages(imagesDir);
}

public void load (FileHandle effectFile, TextureAtlas atlas) {
load(effectFile, atlas, null);
}

public void load (FileHandle effectFile, TextureAtlas atlas, String atlasPrefix) {
loadEmitters(effectFile);
loadEmitterImages(atlas, atlasPrefix);
Expand All @@ -165,6 +169,10 @@ public void loadEmitters (FileHandle effectFile) {
}
}

public void loadEmitterImages (TextureAtlas atlas) {
loadEmitterImages(atlas, null);
}

public void loadEmitterImages (TextureAtlas atlas, String atlasPrefix) {
for (int i = 0, n = emitters.size; i < n; i++) {
ParticleEmitter emitter = emitters.get(i);
Expand All @@ -173,7 +181,7 @@ public void loadEmitterImages (TextureAtlas atlas, String atlasPrefix) {
String imageName = new File(imagePath.replace('\\', '/')).getName();
int lastDotIndex = imageName.lastIndexOf('.');
if (lastDotIndex != -1) imageName = imageName.substring(0, lastDotIndex);
if (atlasPrefix.length() > 0) imageName = atlasPrefix + "/" + imageName;
if (atlasPrefix != null) imageName = atlasPrefix + imageName;
Sprite sprite = atlas.createSprite(imageName);
if (sprite == null) throw new IllegalArgumentException("SpriteSheet missing image: " + imageName);
emitter.setSprite(sprite);
Expand Down

0 comments on commit dc4bbca

Please sign in to comment.