From 6679873c9ba369baa8a52e4673a83e5b9f656897 Mon Sep 17 00:00:00 2001 From: Ali-RS Date: Mon, 11 Feb 2019 08:20:44 +0330 Subject: [PATCH] Added removeAction(), removeLayer() and removeCurrentAction() to AnimComposer (#1016) * Added AnimComposer.removeAction() and AnimComposer.removeLayer() * Added javadoc for AnimComposer.setCurrentAction() * Moved removing of current action to a separate method. * Added javadoc for new methods. --- .../main/java/com/jme3/anim/AnimComposer.java | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/anim/AnimComposer.java b/jme3-core/src/main/java/com/jme3/anim/AnimComposer.java index fee34aceb..38efa5d2a 100644 --- a/jme3-core/src/main/java/com/jme3/anim/AnimComposer.java +++ b/jme3-core/src/main/java/com/jme3/anim/AnimComposer.java @@ -67,17 +67,40 @@ public class AnimComposer extends AbstractControl { public Action setCurrentAction(String name) { return setCurrentAction(name, DEFAULT_LAYER); } - + + /** + * Run an action on specified layer. + * + * @param actionName The name of the action to run. + * @param layerName The layer on which action should run. + * @return The action corresponding to the given name. + */ public Action setCurrentAction(String actionName, String layerName) { Layer l = layers.get(layerName); if (l == null) { throw new IllegalArgumentException("Unknown layer " + layerName); } + Action currentAction = action(actionName); l.time = 0; l.currentAction = currentAction; return currentAction; } + + /** + * Remove current action on specified layer. + * + * @param layerName The name of the layer we want to remove it's action. + */ + public void removeCurrentAction(String layerName) { + Layer l = layers.get(layerName); + if (l == null) { + throw new IllegalArgumentException("Unknown layer " + layerName); + } + + l.time = 0; + l.currentAction = null; + } public Action action(String name) { Action action = actions.get(name); @@ -101,13 +124,31 @@ public class AnimComposer extends AbstractControl { public boolean hasAction(String name) { return actions.containsKey(name); } + + /** + * Remove specified action. + * + * @param name The name of the action to remove. + * @return The removed action. + */ + public Action removeAction(String name) { + return actions.remove(name); + } - public void makeLayer(String name, AnimationMask mask){ + public void makeLayer(String name, AnimationMask mask) { Layer l = new Layer(); l.mask = mask; layers.put(name, l); } + /** + * Remove specified layer. This will stop the current action on this layer. + * + * @param name The name of the layer to remove. + */ + public void removeLayer(String name) { + layers.remove(name); + } public BaseAction actionSequence(String name, Tween... tweens) { BaseAction action = new BaseAction(Tweens.sequence(tweens));