Rather than having each bitmap register its own enterFrame callback, let's just set these guys up as tickable and let the central Ticker handle it.

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@977 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Mike Thomas
2010-08-11 20:10:25 +00:00
parent 407af70322
commit 78391781ab
2 changed files with 19 additions and 4 deletions
@@ -26,6 +26,7 @@ import flash.geom.Point;
import flash.geom.Rectangle;
import com.threerings.display.DisplayUtil;
import com.threerings.miso.client.Tickable;
import com.threerings.util.DirectionCodes;
import com.threerings.util.Log;
@@ -34,6 +35,7 @@ import com.threerings.util.Log;
* about in a scene.
*/
public class CharacterSprite extends Sprite
implements Tickable
{
private static var log :Log = Log.getLog(CharacterSprite);
@@ -62,6 +64,13 @@ public class CharacterSprite extends Sprite
updateActionFrames();
}
public function tick (tickStamp :int) :void
{
if (_framesBitmap != null) {
_framesBitmap.tick(tickStamp);
}
}
/**
* Called after this sprite has been initialized with its character
* descriptor and character manager. Derived classes can do post-init
@@ -221,9 +230,11 @@ public class CharacterSprite extends Sprite
DisplayUtil.removeAllChildren(_mainSprite);
if (_aframes != null) {
_aframes.getFrames(_orient, function(frames :MultiFrameBitmap) :void {
_framesBitmap = frames;
_mainSprite.addChild(frames);
});
} else {
_framesBitmap = null;
updateWithUnloadedSprite();
}
}
@@ -277,6 +288,9 @@ public class CharacterSprite extends Sprite
* orientation. */
protected var _aframes :ActionFrames;
/** The currently active set of bitmaps for this character. */
protected var _framesBitmap :MultiFrameBitmap;
/** The offset from the upper-left of the total sprite bounds to the
* upper-left of the image within those bounds. */
protected var _ioff :Point = new Point();