Enough AS cast implementation to render a basic character sprite from component bundles.

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@970 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Mike Thomas
2010-08-10 20:28:25 +00:00
parent 4b09709590
commit 57f020afb8
17 changed files with 1829 additions and 6 deletions
@@ -53,6 +53,17 @@ public class CharacterComponent
_frameProvider = fprov;
}
public function setFrameProvider (frameProvider :FrameProvider) :void
{
_frameProvider = frameProvider;
// Notify them all and clear our list.
for each (var func :Function in _notifyOnLoad) {
func(this);
}
_notifyOnLoad = [];
}
/**
* Returns the render priority appropriate for this component at the specified action and
* orientation.
@@ -71,7 +82,7 @@ public class CharacterComponent
*/
public function getFrames (action :String, type :String) :ActionFrames
{
return _frameProvider.getFrames(this, action, type);
return isLoaded() ? _frameProvider.getFrames(this, action, type) : null;
}
/**
@@ -104,10 +115,29 @@ public class CharacterComponent
public function toString () :String
{
return StringUtil.toString(this);
return StringUtil.simpleToString(this);
}
public function isLoaded () :Boolean
{
return _frameProvider != null;
}
public function notifyOnLoad (func :Function) :void
{
if (isLoaded()) {
func(this);
} else {
_notifyOnLoad.push(func);
}
}
/** The entity from which we obtain our animation frames. */
protected var _frameProvider :FrameProvider;
/** Everyone who cares when we're loaded. */
protected var _notifyOnLoad :Array = [];
}
}