From 4b100da3bd8fc781c18b1ddfec1aebe9a808d0c1 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 8 Mar 2002 22:35:55 +0000 Subject: [PATCH] Added support for changing a sprite's character descriptor in situ. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1110 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/cast/CharacterSprite.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/cast/CharacterSprite.java b/src/java/com/threerings/cast/CharacterSprite.java index 59995d82e..e6dc06d32 100644 --- a/src/java/com/threerings/cast/CharacterSprite.java +++ b/src/java/com/threerings/cast/CharacterSprite.java @@ -1,5 +1,5 @@ // -// $Id: CharacterSprite.java,v 1.22 2002/03/04 22:47:06 mdb Exp $ +// $Id: CharacterSprite.java,v 1.23 2002/03/08 22:35:55 mdb Exp $ package com.threerings.cast; @@ -29,6 +29,18 @@ public class CharacterSprite _orient = NORTH; } + /** + * Reconfigures this sprite to use the specified character descriptor. + */ + public void setCharacterDescriptor (CharacterDescriptor descrip) + { + // keep the new descriptor + _descrip = descrip; + + // reset our action which will reload our frames + setActionSequence(_action); + } + /** * Specifies the action to use when the sprite is at rest. The default * is STANDING. @@ -53,6 +65,10 @@ public class CharacterSprite */ public void setActionSequence (String action) { + // keep track of our current action in case someone swaps out our + // character description + _action = action; + // get a reference to the action sequence so that we can obtain // our animation frames and configure our frames per second ActionSequence actseq = _charmgr.getActionSequence(action); @@ -162,6 +178,9 @@ public class CharacterSprite /** A reference to the character manager that created us. */ protected CharacterManager _charmgr; + /** The action we are currently displaying. */ + protected String _action; + /** The animation frames for the active action sequence in each * orientation. */ protected MultiFrameImage[] _frames;