Closed LeeLorenzSr closed 9 years ago
I will look at reverting it and allowing another way to pass in the atlas.
I'm glad you are finding it useful. Let me know when your project is done.
I accidentally hit "fork" so I went ahead and coded something up on my github - I haven't tested it yet. I just passed the atlas parameter down to the parser, where the entity constructor can accept a default atlas parameter to set. I've used this spriter code in two of my mobile projects that are out - Conk the Roach and 21st Century Video Poker. I'm adding it into an older project at the moment to improve my animations.
I've just updated the library.
You can pass a default atlas the same way as before. Or you can override on a per entity basis.
Let me know if this works for you.
Close, but it still doesn't pass the "default" atlas down to the entity. In my fork, I added an atlas parameter to the entity constructor, and passed the atlas into the parser, so when it constructed the entity, it assigned the atlas (or null, the default value for the parameter)
public function Entity(defAtlas:TextureAtlas=null)
{
this.atlas = defAtlas;
}
I pass it through the parser, which takes an atlas parameter...
public static function parse (spriteAnim:SpriterAnimation, data:XML, atlas:TextureAtlas = null, entities:Array = null, animations:Array = null):void
{
for each(var folderXml:XML in data.folder)
{
var folder:Folder = new Folder ();
folder.parseXML (folderXml);
spriteAnim.folders.push (folder);
}
for each(var entityXml:XML in data.entity)
{
var entity:Entity = new Entity (atlas);
entity.name = entityXml.@name;
entity.entityData = entityXml;
if (entities == null || entities.indexOf (entity.name) != -1)
{
entity.parseXML (spriteAnim, animations);
}
spriteAnim.entities.push (entity);
}
}
Sorry missed 1 line when checking in.
public function SpriterAnimation(name:String, data:*, atlas:TextureAtlas = null, entities:Array = null, animations:Array = null)
{
this.name = name;
this.atlas = atlas;
and in the playback
var entity:Entity = animation.entities[currentEntity] as Entity;
var anim:Animation = entity.animations[currentAnimation] as Animation;
curAtlas = entity.atlas;
if (!curAtlas)
{
curAtlas = animation.atlas;
}
var image:Image;
if (anim && curAtlas)
{
it gets the entites atlas or if null defaults to the one on the animation when created.
Loks good now, thanks for the quick response!
I'm not sure why it was done, but you've made it far more cumbersome to assign an atlas to the animation. Rather than a single place, we now apparently can only assign an atlas to the currently used entity? I would prefer to see the ability to assign the atlas specifically, but also keep the original, legacy constructor code, so all of my projects don't break and require re-writing when updating with the new source.
I actually have not had any situation that called for unique atlas sets between animation entities on the same spriter. If I need to change a texture set (for costuming or theming) they will typically be in one atlas for all of a set of animations per theme or costume.
The way it is set up now, however, I think it is even more difficult to actually use.
Thanks for the hard work, though... on a side note, I'm making good use of the color tinting (Vertex coloring) to provide some differentiation in some of the characters on one of my projects.