I’m having an issue switching between animations. Currently I have a class that contains an animation control and a list of animation channels. I have one channel for each animation for the object. I’m trying to switch animations by stopping one channel and playing the next but only the first animation stops and the second one never plays.
public void stop(String name,String animation){
for (AnimationObject x : animationList) {
if (x.name.equals(name)) {
for (AnimChannel c : x.channels){
if (c.getAnimationName().equals(animation)){
c.setSpeed(0);
}
}
}
}
}
public void play(String name,String animation,Float speed){
for (AnimationObject x : animationList) {
if (x.name.equals(name)) {
for (AnimChannel c : x.channels){
if (c.getAnimationName().equals(animation)){
c.setLoopMode(LoopMode.Loop);
c.setAnim(animation);
c.setSpeed(speed);
}
}
}
}
}
//code to stop and play
myWorld.animation.stop("jessica", "run");
myWorld.animation.play("jessica", "walk", 1f);