public addFrame ( |
||
subtexture | Subtexture. | |
return |
/// <summary> /// returns a SpriteAnimation given an animationName where the animationName is the region's "filename" metadata /// in the TexturePacker atlas minus the framenumbers at the end /// </summary> /// <returns>The sprite animation.</returns> /// <param name="animationName">Animation name.</param> public SpriteAnimation getSpriteAnimation( string animationName ) { // create the cache Dictionary if necessary. Return the animation direction if already cached. if( _spriteAnimations == null ) _spriteAnimations = new Dictionary<string,SpriteAnimation>(); else if( _spriteAnimations.ContainsKey( animationName ) ) return _spriteAnimations[animationName]; if( spriteAnimationDetails.ContainsKey( animationName ) ) { var frames = spriteAnimationDetails[animationName]; var animation = new SpriteAnimation { fps = _animationFPS }; for( var i = 0; i < frames.Count; i++ ) animation.addFrame( subtextures[frames[i]] ); _spriteAnimations[animationName] = animation; return animation; } throw new KeyNotFoundException( animationName ); }
/// <summary> /// returns a SpriteAnimation given an animationName where the animationName is the folder that contains the images /// </summary> /// <returns>The sprite animation.</returns> /// <param name="animationName">Animation name.</param> public SpriteAnimation getSpriteAnimation( string animationName ) { Point point; if( _spriteAnimationDetails.TryGetValue( animationName, out point ) ) { var animation = new SpriteAnimation { fps = _animationFPS }; for( var i = point.X; i <= point.Y; i++ ) animation.addFrame( subtextures[i] ); return animation; } throw new KeyNotFoundException( animationName ); }