AnimationTrack null checked the animation channel in onStop, onPause and setLoopMode to avoid NPE

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9288 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 13 years ago
parent bc0207f1fc
commit c3ed68cfbb
  1. 20
      engine/src/core/com/jme3/cinematic/events/AnimationTrack.java

@ -146,18 +146,16 @@ public class AnimationTrack extends AbstractCinematicEvent {
channel.setSpeed(speed); channel.setSpeed(speed);
channel.setLoopMode(loopMode); channel.setLoopMode(loopMode);
channel.setTime(time); channel.setTime(time);
} }
} }
@Override @Override
public void setSpeed(float speed) { public void setSpeed(float speed) {
super.setSpeed(speed); super.setSpeed(speed);
if(channel!=null){ if (channel != null) {
channel.setSpeed(speed); channel.setSpeed(speed);
} }
} }
@Override @Override
public void onUpdate(float tpf) { public void onUpdate(float tpf) {
@ -165,19 +163,25 @@ public class AnimationTrack extends AbstractCinematicEvent {
@Override @Override
public void onStop() { public void onStop() {
channel.setTime(0); if (channel != null) {
channel.reset(false); channel.setTime(0);
channel.reset(false);
}
} }
@Override @Override
public void onPause() { public void onPause() {
channel.getControl().setEnabled(false); if (channel != null) {
channel.getControl().setEnabled(false);
}
} }
@Override @Override
public void setLoopMode(LoopMode loopMode) { public void setLoopMode(LoopMode loopMode) {
super.setLoopMode(loopMode); super.setLoopMode(loopMode);
channel.setLoopMode(loopMode); if (channel != null) {
channel.setLoopMode(loopMode);
}
} }
@Override @Override

Loading…
Cancel
Save