From 2ef4dc2a222ed0f81b1ca6820bd1313a898eca3c Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 4 Jan 2006 23:08:48 +0000 Subject: [PATCH] Added methods to set animation repeat type in addition to active state and speed. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3800 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/jme/sprite/Sprite.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/jme/sprite/Sprite.java b/src/java/com/threerings/jme/sprite/Sprite.java index 4e28a7b96..7b7301ebf 100644 --- a/src/java/com/threerings/jme/sprite/Sprite.java +++ b/src/java/com/threerings/jme/sprite/Sprite.java @@ -67,6 +67,23 @@ public class Sprite extends Node } } + /** + * Walks down the hierarchy provided setting the animation repeat type on + * any controllers found along the way. + */ + public static void setAnimationRepeatType (Spatial spatial, int repeatType) + { + for (int ii = 0; ii < spatial.getControllers().size(); ii++) { + spatial.getController(ii).setRepeatType(repeatType); + } + if (spatial instanceof Node) { + Node node = (Node)spatial; + for (int ii = 0; ii < node.getQuantity(); ii++) { + setAnimationRepeatType(node.getChild(ii), repeatType); + } + } + } + public Sprite () { super(""); @@ -157,13 +174,21 @@ public class Sprite extends Node } /** - * Configures the speed of all controllers in our model hierarchy. + * Configures the active state of all controllers in our model hierarchy. */ public void setAnimationActive (boolean active) { setAnimationActive(this, active); } + /** + * Configures the repeat type of all controllers in our model hierarchy. + */ + public void setAnimationRepeatType (int repeatType) + { + setAnimationRepeatType(this, repeatType); + } + /** Used to dispatch {@link PathObserver#pathCancelled}. */ protected static class CancelledOp implements ObserverList.ObserverOp {