Fix up to avoid infinite recursion on Effect.effectNameToInt
This commit is contained in:
parent
f718db851c
commit
c42cd14aaa
1 changed files with 17 additions and 6 deletions
|
@ -19,6 +19,7 @@ package io.github.lonamiwebs.klooni;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.audio.Sound;
|
import com.badlogic.gdx.audio.Sound;
|
||||||
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
|
@ -44,9 +45,18 @@ public class Effect {
|
||||||
|
|
||||||
// This method will load the sound "sound/effect_{effectName}.mp3"
|
// This method will load the sound "sound/effect_{effectName}.mp3"
|
||||||
public Effect(final String effectName) {
|
public Effect(final String effectName) {
|
||||||
|
this(effectName, effectNameToInt(effectName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Effect(final String effectName, final int id) {
|
||||||
name = effectName;
|
name = effectName;
|
||||||
effectId = effectNameToInt(name);
|
effectId = id;
|
||||||
effectSound = Gdx.audio.newSound(Gdx.files.internal("sound/effect_" + name + ".mp3"));
|
|
||||||
|
FileHandle soundFile = Gdx.files.internal("sound/effect_" + name + ".mp3");
|
||||||
|
if (!soundFile.exists())
|
||||||
|
soundFile = Gdx.files.internal("sound/effect_vanish.mp3");
|
||||||
|
|
||||||
|
effectSound = Gdx.audio.newSound(soundFile);
|
||||||
price = effectId == 0 ? 0 : 200; // TODO For now they're all 200 coins except the first
|
price = effectId == 0 ? 0 : 200; // TODO For now they're all 200 coins except the first
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,11 +78,12 @@ public class Effect {
|
||||||
//region Static methods
|
//region Static methods
|
||||||
|
|
||||||
public static Effect[] getEffects() {
|
public static Effect[] getEffects() {
|
||||||
|
int id = 0;
|
||||||
return new Effect[] {
|
return new Effect[] {
|
||||||
new Effect("vanish"),
|
new Effect("vanish", id++),
|
||||||
new Effect("waterdrop"),
|
new Effect("waterdrop", id++),
|
||||||
new Effect("evaporate"),
|
new Effect("evaporate", id++),
|
||||||
new Effect("spin")
|
new Effect("spin", id++)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue