We can't use setActionSequence(_action) to force our frames to be reloaded
because it's smart about that now. So we break out the reloading where necessary. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2198 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: CharacterSprite.java,v 1.41 2003/01/18 03:13:08 mdb Exp $
|
// $Id: CharacterSprite.java,v 1.42 2003/01/20 20:28:51 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cast;
|
package com.threerings.cast;
|
||||||
|
|
||||||
@@ -53,8 +53,8 @@ public class CharacterSprite extends ImageSprite
|
|||||||
// keep the new descriptor
|
// keep the new descriptor
|
||||||
_descrip = descrip;
|
_descrip = descrip;
|
||||||
|
|
||||||
// reset our action which will reload our frames
|
// update our action frames
|
||||||
setActionSequence(_action);
|
updateActionFrames();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,22 +105,28 @@ public class CharacterSprite extends ImageSprite
|
|||||||
if (action.equals(_action)) {
|
if (action.equals(_action)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep track of our current action in case someone swaps out our
|
|
||||||
// character descriptor
|
|
||||||
_action = action;
|
_action = action;
|
||||||
|
updateActionFrames();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rebuilds our action frames given our current character descriptor
|
||||||
|
* and action sequence. This is called when either of those two things
|
||||||
|
* changes.
|
||||||
|
*/
|
||||||
|
protected void updateActionFrames ()
|
||||||
|
{
|
||||||
// get a reference to the action sequence so that we can obtain
|
// get a reference to the action sequence so that we can obtain
|
||||||
// our animation frames and configure our frames per second
|
// our animation frames and configure our frames per second
|
||||||
ActionSequence actseq = _charmgr.getActionSequence(action);
|
ActionSequence actseq = _charmgr.getActionSequence(_action);
|
||||||
if (actseq == null) {
|
if (actseq == null) {
|
||||||
String errmsg = "No such action '" + action + "'.";
|
String errmsg = "No such action '" + _action + "'.";
|
||||||
throw new IllegalArgumentException(errmsg);
|
throw new IllegalArgumentException(errmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// obtain our animation frames for this action sequence
|
// obtain our animation frames for this action sequence
|
||||||
_aframes = _charmgr.getActionFrames(_descrip, action);
|
_aframes = _charmgr.getActionFrames(_descrip, _action);
|
||||||
|
|
||||||
// clear out our frames so that we recomposite on next tick
|
// clear out our frames so that we recomposite on next tick
|
||||||
_frames = null;
|
_frames = null;
|
||||||
@@ -279,8 +285,8 @@ public class CharacterSprite extends ImageSprite
|
|||||||
super.pathBeginning();
|
super.pathBeginning();
|
||||||
|
|
||||||
// enable walking animation
|
// enable walking animation
|
||||||
setActionSequence(getFollowingPathAction());
|
|
||||||
setAnimationMode(TIME_BASED);
|
setAnimationMode(TIME_BASED);
|
||||||
|
setActionSequence(getFollowingPathAction());
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
|
|||||||
Reference in New Issue
Block a user