Added some methods for controlling animations within a sprite.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3583 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
package com.threerings.jme.sprite;
|
package com.threerings.jme.sprite;
|
||||||
|
|
||||||
import com.jme.scene.Node;
|
import com.jme.scene.Node;
|
||||||
|
import com.jme.scene.Spatial;
|
||||||
|
|
||||||
import com.samskivert.util.ObserverList;
|
import com.samskivert.util.ObserverList;
|
||||||
|
|
||||||
@@ -113,6 +114,54 @@ public class Sprite extends Node
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the speed of all controllers in our model hierarchy.
|
||||||
|
*/
|
||||||
|
public void setAnimationSpeed (float speed)
|
||||||
|
{
|
||||||
|
setAnimationSpeed(this, speed);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the speed of all controllers in our model hierarchy.
|
||||||
|
*/
|
||||||
|
public void setAnimationActive (boolean active)
|
||||||
|
{
|
||||||
|
setAnimationActive(this, active);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function for {@link #setAnimationSpeed(float)}.
|
||||||
|
*/
|
||||||
|
protected static void setAnimationSpeed (Spatial spatial, float speed)
|
||||||
|
{
|
||||||
|
for (int ii = 0; ii < spatial.getControllers().size(); ii++) {
|
||||||
|
spatial.getController(ii).setSpeed(speed);
|
||||||
|
}
|
||||||
|
if (spatial instanceof Node) {
|
||||||
|
Node node = (Node)spatial;
|
||||||
|
for (int ii = 0; ii < node.getQuantity(); ii++) {
|
||||||
|
setAnimationSpeed(node.getChild(ii), speed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function for {@link #setAnimationActive(boolean)}.
|
||||||
|
*/
|
||||||
|
protected static void setAnimationActive (Spatial spatial, boolean active)
|
||||||
|
{
|
||||||
|
for (int ii = 0; ii < spatial.getControllers().size(); ii++) {
|
||||||
|
spatial.getController(ii).setActive(active);
|
||||||
|
}
|
||||||
|
if (spatial instanceof Node) {
|
||||||
|
Node node = (Node)spatial;
|
||||||
|
for (int ii = 0; ii < node.getQuantity(); ii++) {
|
||||||
|
setAnimationActive(node.getChild(ii), active);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Used to dispatch {@link PathObserver#pathCancelled}. */
|
/** Used to dispatch {@link PathObserver#pathCancelled}. */
|
||||||
protected static class CancelledOp implements ObserverList.ObserverOp
|
protected static class CancelledOp implements ObserverList.ObserverOp
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user