addFrame() public méthode

adds a frame to this animation
public addFrame ( Subtexture subtexture ) : SpriteAnimation
subtexture Nez.Textures.Subtexture Subtexture.
Résultat SpriteAnimation
Exemple #1
0
		/// <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 );
		}
Exemple #2
0
        /// <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 );
        }