5252 * @author Nehon
5353 */
5454public class AnimComposer extends AbstractControl {
55+
5556 /**
5657 * The name of the default layer.
5758 */
@@ -121,7 +122,7 @@ public void removeAnimClip(AnimClip anim) {
121122 * @return The action corresponding to the given name.
122123 */
123124 public Action setCurrentAction (String name ) {
124- return setCurrentAction (name , DEFAULT_LAYER );
125+ return setCurrentAction (name , DEFAULT_LAYER , true );
125126 }
126127
127128 /**
@@ -144,9 +145,9 @@ public Action setCurrentAction(String actionName, String layerName) {
144145 * @return The action corresponding to the given name.
145146 */
146147 public Action setCurrentAction (String actionName , String layerName , boolean loop ) {
147- AnimLayer l = getLayer (layerName );
148+ AnimLayer layer = getLayer (layerName );
148149 Action currentAction = action (actionName );
149- l .setCurrentAction (actionName , currentAction , loop );
150+ layer .setCurrentAction (actionName , currentAction , loop );
150151
151152 return currentAction ;
152153 }
@@ -239,7 +240,8 @@ public void setTime(String layerName, double time) {
239240 /**
240241 *
241242 * @param name The name of the action to return.
242- * @return The action registered with specified name. It will make a new action if there isn't any.
243+ * @return The action registered with specified name. It will make a new
244+ * action if there isn't any.
243245 * @see #makeAction(java.lang.String)
244246 */
245247 public Action action (String name ) {
@@ -254,7 +256,8 @@ public Action action(String name) {
254256 /**
255257 *
256258 * @param name The name of the action to return.
257- * @return The action registered with specified name or null if nothing is registered.
259+ * @return The action registered with specified name or null if nothing is
260+ * registered.
258261 */
259262 public Action getAction (String name ) {
260263 return actions .get (name );
@@ -331,8 +334,8 @@ public AnimLayer removeLayer(String name) {
331334 }
332335
333336 /**
334- * Creates an action that will interpolate over an entire sequence
335- * of tweens in order.
337+ * Creates an action that will interpolate over an entire sequence of tweens
338+ * in order.
336339 *
337340 * @param name a name for the new Action
338341 * @param tweens the desired sequence of tweens
@@ -374,8 +377,9 @@ public void reset() {
374377 }
375378
376379 /**
377- * Returns an unmodifiable collection of all available animations. When an attempt
378- * is made to modify the collection, an UnsupportedOperationException is thrown.
380+ * Returns an unmodifiable collection of all available animations. When an
381+ * attempt is made to modify the collection, an
382+ * UnsupportedOperationException is thrown.
379383 *
380384 * @return the unmodifiable collection of animations
381385 */
@@ -526,7 +530,9 @@ public void cloneFields(Cloner cloner, Object original) {
526530 for (String key : layers .keySet ()) {
527531 newLayers .put (key , cloner .clone (layers .get (key )));
528532 }
529-
533+ if (!newLayers .containsKey (DEFAULT_LAYER )) {
534+ newLayers .put (DEFAULT_LAYER , new AnimLayer (DEFAULT_LAYER , null ));
535+ }
530536 layers = newLayers ;
531537
532538 }
@@ -546,6 +552,9 @@ public void read(JmeImporter im) throws IOException {
546552 animClipMap = (Map <String , AnimClip >) ic .readStringSavableMap ("animClipMap" , new HashMap <String , AnimClip >());
547553 globalSpeed = ic .readFloat ("globalSpeed" , 1f );
548554 layers = (Map <String , AnimLayer >) ic .readStringSavableMap ("layers" , new HashMap <String , AnimLayer >());
555+ if (!layers .containsKey (DEFAULT_LAYER )) {
556+ layers .put (DEFAULT_LAYER , new AnimLayer (DEFAULT_LAYER , null ));
557+ }
549558 }
550559
551560 /**
0 commit comments