Пример #1
0
 /// <summary>Sets the animationIndex for this to the given animationIndex.</summary>
 /// <remarks>
 /// Sets the animationIndex for this to the given animationIndex.
 /// This method can make sure that the switching between to animations is smooth.
 /// By setting transitionSpeed and transitionSteps to appropriate values, you can have nice transitions between two animations.
 /// Setting transitionSpeed to 1 and transitionSteps to 20 means, that this player will need 20 steps to translate the current animation to the given one.
 /// </remarks>
 /// <param name="animationIndex">
 /// Index of animation to set. Get the index with
 /// <see cref="getAnimationIndexByName(string)">getAnimationIndexByName(string)</see>
 /// .
 /// </param>
 /// <param name="transitionSpeed">Speed for the switch between the current animation and the one which has been set.
 ///     </param>
 /// <param name="transitionSteps">Steps needed for the transition</param>
 /// <exception cref="System.Exception"></exception>
 public virtual void setAnimatioIndex(int animationIndex, int transitionSpeed, int
                                      transitionSteps)
 {
     if (animationIndex >= this.entity.getAnimation().Count || animationIndex < 0)
     {
         throw new System.Exception("The given animation index does not exist: " + animationIndex
                                    + "\n" + "Index range goes from 0 to " + (this.entity.getAnimation().Count - 1)
                                    );
     }
     if (this.animationIndex != animationIndex)
     {
         if (this.transitionFixed)
         {
             this.lastRealFrame       = this.lastFrame;
             this.transitionFixed     = false;
             this.transitionTempFixed = true;
         }
         else
         {
             this.lastRealFrame       = this.lastTempFrame;
             this.transitionTempFixed = false;
             this.transitionFixed     = true;
         }
         this.transitionSpeed = transitionSpeed;
         this.fixMaxSteps     = transitionSteps;
         this.lastRealFrame.setTime(this.frame + 1);
         this.animation = this.animations[animationIndex];
         this.animation.frames[0].setTime(this.frame + 1 + this.fixMaxSteps);
         this.currentKey     = 0;
         this.fixCounter     = 0;
         this.animationIndex = animationIndex;
     }
 }
Пример #2
0
 /// <summary>Constructs a new SpriterPlayer object which animates the given Spriter entity.
 ///     </summary>
 /// <remarks>Constructs a new SpriterPlayer object which animates the given Spriter entity.
 ///     </remarks>
 /// <param name="data">
 ///
 /// <see cref="SpriterData">SpriterData
 ///     </see>
 /// which provides a method to load all needed data to animate. See
 /// <see cref="Spriter#getSpriter(String,com.spriter.file.FileLoader)">Spriter#getSpriter(String,com.spriter.file.FileLoader)
 ///     </see>
 /// for mor information.
 /// </param>
 /// <param name="entityIndex">The entity which should be handled by this player.</param>
 /// <param name="loader">The loader which has loaded all necessary sprites for the scml file.
 ///     </param>
 public SpriterPlayer(SpriterData data, Entity
                      entity, FileLoader loader) : base(loader, null)
 {
     this.entity = entity;
     this.frame  = 0;
     if (!alreadyLoaded(entity))
     {
         this.animations = SpriterKeyFrameProvider.generateKeyFramePool(data, entity);
         loaded.Add(entity, this);
     }
     else
     {
         this.animations = loaded[entity].animations;
     }
     this.generateData();
     this.animation     = this.animations[0];
     this.firstKeyFrame = this.animation.frames[0];
     this.update(0, 0);
 }
Пример #3
0
        /// <summary>Sets the animationIndex for this to the given animationIndex.</summary>
        /// <remarks>
        /// Sets the animationIndex for this to the given animationIndex.
        /// This method can make sure that the switching between to animations is smooth.
        /// By setting transitionSpeed and transitionSteps to appropriate values, you can have nice transitions between two animations.
        /// Setting transitionSpeed to 1 and transitionSteps to 20 means, that this player will need 20 steps to translate the current animation to the given one.
        /// </remarks>
        /// <param name="animationIndex">
        /// Index of animation to set. Get the index with
        /// <see cref="getAnimationIndexByName(string)">getAnimationIndexByName(string)</see>
        /// .
        /// </param>
        /// <param name="transitionSpeed">Speed for the switch between the current animation and the one which has been set.
        /// 	</param>
        /// <param name="transitionSteps">Steps needed for the transition</param>
        /// <exception cref="System.Exception"></exception>
        public virtual void setAnimatioIndex(int animationIndex, int transitionSpeed, int
			 transitionSteps)
        {
            if (animationIndex >= this.entity.getAnimation().Count || animationIndex < 0)
            {
                throw new System.Exception("The given animation index does not exist: " + animationIndex
                     + "\n" + "Index range goes from 0 to " + (this.entity.getAnimation().Count - 1)
                    );
            }
            if (this.animationIndex != animationIndex)
            {
                if (this.transitionFixed)
                {
                    this.lastRealFrame = this.lastFrame;
                    this.transitionFixed = false;
                    this.transitionTempFixed = true;
                }
                else
                {
                    this.lastRealFrame = this.lastTempFrame;
                    this.transitionTempFixed = false;
                    this.transitionFixed = true;
                }
                this.transitionSpeed = transitionSpeed;
                this.fixMaxSteps = transitionSteps;
                this.lastRealFrame.setTime(this.frame + 1);
                this.animation = this.animations[animationIndex];
                this.animation.frames[0].setTime(this.frame + 1 + this.fixMaxSteps);
                this.currentKey = 0;
                this.fixCounter = 0;
                this.animationIndex = animationIndex;
            }
        }
Пример #4
0
        /// <summary>Constructs a new SpriterPlayer object which animates the given Spriter entity.
        /// 	</summary>
        /// <remarks>Constructs a new SpriterPlayer object which animates the given Spriter entity.
        /// 	</remarks>
        /// <param name="data">
        /// 
        /// <see cref="SpriterData">SpriterData
        /// 	</see>
        /// which provides a method to load all needed data to animate. See
        /// <see cref="Spriter#getSpriter(String,com.spriter.file.FileLoader)">Spriter#getSpriter(String,com.spriter.file.FileLoader)
        /// 	</see>
        /// for mor information.
        /// </param>
        /// <param name="entityIndex">The entity which should be handled by this player.</param>
        /// <param name="loader">The loader which has loaded all necessary sprites for the scml file.
        /// 	</param>
        public SpriterPlayer(SpriterData data, Entity
			 entity, FileLoader loader)
            : base(loader, null)
        {
            this.entity = entity;
            this.frame = 0;
            if (!alreadyLoaded(entity))
            {
                this.animations = SpriterKeyFrameProvider.generateKeyFramePool(data, entity);
                loaded.Add(entity, this);
            }
            else
            {
                this.animations = loaded[entity].animations;
            }
            this.generateData();
            this.animation = this.animations[0];
            this.firstKeyFrame = this.animation.frames[0];
            this.update(0, 0);
        }