Reset() public method

Resets the animation sequence for playing anew.
public Reset ( ) : void
return void
コード例 #1
0
    /// <summary>
    /// Like PlayAnim, but plays the animation in reverse.
    /// See <see cref="PlayAnim"/>.
    /// </summary>
    /// <param name="anim">Reference to the animation to play in reverse.</param>
    public void PlayAnimInReverse(UVAnimation_Multi anim)
    {
#if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9
        if (deleted || !gameObject.activeInHierarchy)
#else
        if (deleted || !gameObject.active)
#endif
        { return; }
        if (!m_started)
        {
            Start();
        }

        curAnim = anim;
        curAnim.Reset();
        curAnim.PlayInReverse();

        // Ensure the framerate is not 0 so we don't
        // divide by zero:
        if (anim.framerate != 0.0f)
        {
            timeBetweenAnimFrames = 1f / anim.framerate;
        }
        else
        {
            timeBetweenAnimFrames = 1f;             // Just some dummy value since it won't be used
        }

        timeSinceLastFrame = timeBetweenAnimFrames;

        // Only add to the animated list if
        // the animation has more than 1 frame:
        if ((anim.GetFrameCount() > 1 || anim.onAnimEnd != UVAnimation.ANIM_END_ACTION.Do_Nothing) && anim.framerate != 0.0f)
        {
            StepAnim(0);
            // Start coroutine
            if (!animating)
            {
                //animating = true;
                AddToAnimatedList();
                //StartCoroutine(AnimationPump());
            }
        }
        else
        {
            // Make sure we are no longer in the animation pump:
            PauseAnim();

            // Since this is a single-frame anim,
            // call our delegate before setting
            // the frame so that our behavior is
            // consistent with multi-frame anims:
            if (animCompleteDelegate != null)
            {
                animCompleteDelegate(this);
            }

            StepAnim(0);
        }
    }
コード例 #2
0
/*
 *      // Steps to the next frame of sprite animation
 *      public override bool StepAnim()
 *      {
 *              if (curAnim == null)
 *                      return false;
 *
 *              if (!curAnim.GetNextFrame(ref uvRect))
 *              {
 *                      // We reached the end of our animation
 *
 *                      // See if we should revert to a static appearance,
 *                      // default anim, or do nothing:
 *                      if (curAnim.onAnimEnd == UVAnimation.ANIM_END_ACTION.Do_Nothing)
 *                      {
 *                              PauseAnim();
 *
 *                              // Update mesh UVs:
 *                              SetBleedCompensation();
 *
 *                              // Resize if selected:
 *                              if (autoResize || pixelPerfect)
 *                                      CalcSize();
 *                      }
 *                      else if (curAnim.onAnimEnd == UVAnimation.ANIM_END_ACTION.Revert_To_Static)
 *                              RevertToStatic();
 *                      else if (curAnim.onAnimEnd == UVAnimation.ANIM_END_ACTION.Play_Default_Anim)
 *                      {
 *                              // Notify the delegate:
 *                              if (animCompleteDelegate != null)
 *                                      animCompleteDelegate();
 *
 *                              // Play the default animation:
 *                              PlayAnim(defaultAnim);
 *
 *                              return false;
 *                      }
 *
 *                      // Notify the delegate:
 *                      if (animCompleteDelegate != null)
 *                              animCompleteDelegate();
 *
 *                      // Check to see if we are still animating
 *                      // before setting the curAnim to null.
 *                      // Animating should be turned off if
 *                      // PauseAnim() was called above, or if we
 *                      // reverted to static.  But it could have
 *                      // been turned on again by the
 *                      // animCompleteDelegate.
 *                      if (!animating)
 *                              curAnim = null;
 *
 *                      return false;
 *              }
 *
 *              // Update mesh UVs:
 *              SetBleedCompensation();
 *
 *              UpdateUVs();
 *
 *              // Resize if selected:
 *              if (autoResize || pixelPerfect)
 *                      CalcSize();
 *
 *              return true;
 *      }*/


    /// <summary>
    /// Starts playing the specified animation
    /// Note: this doesn't resume from a pause,
    /// it completely restarts the animation. To
    /// unpause, use <see cref="UnpauseAnim"/>.
    /// </summary>
    /// <param name="anim">A reference to the animation to play.</param>
    public void PlayAnim(UVAnimation_Multi anim)
    {
        if (deleted || !gameObject.active)
        {
            return;
        }

        curAnim      = anim;
        curAnimIndex = curAnim.index;
        curAnim.Reset();

        // Ensure the framerate is not 0 so we don't
        // divide by zero:
        if (anim.framerate != 0.0f)
        {
            timeBetweenAnimFrames = 1f / anim.framerate;
        }
        else
        {
            timeBetweenAnimFrames = 1f;             // Just some dummy value since it won't be used
        }

        timeSinceLastFrame = timeBetweenAnimFrames;

        // Only add to the animated list if
        // the animation has more than 1 frame
        // or the framerate is non-zero:
        if ((anim.GetFrameCount() > 1 || anim.onAnimEnd != UVAnimation.ANIM_END_ACTION.Do_Nothing) && anim.framerate != 0.0f)
        {
            StepAnim(0);
            // Start coroutine
            if (!animating)
            {
                //animating = true;
                AddToAnimatedList();
                //StartCoroutine(AnimationPump());
            }
        }
        else
        {
            // Since this is a single-frame anim,
            // call our delegate before setting
            // the frame so that our behavior is
            // consistent with multi-frame anims:
            if (animCompleteDelegate != null)
            {
                animCompleteDelegate(this);
            }

            StepAnim(0);
        }
    }
コード例 #3
0
    /// <summary>
    /// Stops the current animation from playing
    /// and resets it to the beginning for playing
    /// again.  The sprite then reverts to the static
    /// (non-animating default) image.
    /// </summary>
    public override void StopAnim()
    {
        // Stop coroutine
        //animating = false;
        RemoveFromAnimatedList();

        //StopAllCoroutines();

        // Reset the animation:
        if (curAnim != null)
        {
            curAnim.Reset();
        }

        // Revert to our static appearance:
        RevertToStatic();
    }
コード例 #4
0
    /// <summary>
    /// Like PlayAnim, but plays the animation in reverse.
    /// See <see cref="PlayAnim"/>.
    /// </summary>
    /// <param name="anim">Reference to the animation to play in reverse.</param>
    public void PlayAnimInReverse(UVAnimation_Multi anim)
    {
        curAnim = anim;
        curAnim.Reset();
        curAnim.PlayInReverse();

        // Ensure the framerate is not 0 so we don't
        // divide by zero:
        anim.framerate = Mathf.Max(0.0001f, anim.framerate);

        timeBetweenAnimFrames = 1f / anim.framerate;
        timeSinceLastFrame    = timeBetweenAnimFrames;

        // Only add to the animated list if
        // the animation has more than 1 frame:
        if (anim.GetFrameCount() > 1)
        {
            StepAnim(0);
            // Start coroutine
            if (!animating)
            {
                //animating = true;
                AddToAnimatedList();
                //StartCoroutine(AnimationPump());
            }
        }
        else
        {
            // Since this is a single-frame anim,
            // call our delegate before setting
            // the frame so that our behavior is
            // consistent with multi-frame anims:
            if (animCompleteDelegate != null)
            {
                animCompleteDelegate(this);
            }

            StepAnim(0);
        }
    }
コード例 #5
0
ファイル: Sprite.cs プロジェクト: nbolabs/KnifeLi
	/// <summary>
	/// Like PlayAnim, but plays the animation in reverse.
	/// See <see cref="PlayAnim"/>.
	/// </summary>
	/// <param name="anim">Reference to the animation to play in reverse.</param>
	public void PlayAnimInReverse(UVAnimation_Multi anim)
	{
		if (deleted || !gameObject.active)
			return;
		if (!m_started)
			Start();

		curAnim = anim;
		curAnim.Reset();
		curAnim.PlayInReverse();

		// Ensure the framerate is not 0 so we don't
		// divide by zero:
		if (anim.framerate != 0.0f)
		{
			timeBetweenAnimFrames = 1f / anim.framerate;
		}
		else
		{
			timeBetweenAnimFrames = 1f; // Just some dummy value since it won't be used
		}

		timeSinceLastFrame = timeBetweenAnimFrames;

		// Only add to the animated list if
		// the animation has more than 1 frame:
		if ((anim.GetFrameCount() > 1 || anim.onAnimEnd != UVAnimation.ANIM_END_ACTION.Do_Nothing) && anim.framerate != 0.0f)
		{
			StepAnim(0);
			// Start coroutine
			if (!animating)
			{
				//animating = true;
				AddToAnimatedList();
				//StartCoroutine(AnimationPump());
			}
		}
		else
		{
			// Make sure we are no longer in the animation pump:
			PauseAnim();

			// Since this is a single-frame anim,
			// call our delegate before setting
			// the frame so that our behavior is
			// consistent with multi-frame anims:
			if (animCompleteDelegate != null)
				animCompleteDelegate(this);

			StepAnim(0);
		}
	}
コード例 #6
0
ファイル: Sprite.cs プロジェクト: AtrapadosGame/AtrapadosGame
    /*
        // Steps to the next frame of sprite animation
        public override bool StepAnim()
        {
            if (curAnim == null)
                return false;

            if (!curAnim.GetNextFrame(ref uvRect))
            {
                // We reached the end of our animation

                // See if we should revert to a static appearance,
                // default anim, or do nothing:
                if (curAnim.onAnimEnd == UVAnimation.ANIM_END_ACTION.Do_Nothing)
                {
                    PauseAnim();

                    // Update mesh UVs:
                    SetBleedCompensation();

                    // Resize if selected:
                    if (autoResize || pixelPerfect)
                        CalcSize();
                }
                else if (curAnim.onAnimEnd == UVAnimation.ANIM_END_ACTION.Revert_To_Static)
                    RevertToStatic();
                else if (curAnim.onAnimEnd == UVAnimation.ANIM_END_ACTION.Play_Default_Anim)
                {
                    // Notify the delegate:
                    if (animCompleteDelegate != null)
                        animCompleteDelegate();

                    // Play the default animation:
                    PlayAnim(defaultAnim);

                    return false;
                }

                // Notify the delegate:
                if (animCompleteDelegate != null)
                    animCompleteDelegate();

                // Check to see if we are still animating
                // before setting the curAnim to null.
                // Animating should be turned off if
                // PauseAnim() was called above, or if we
                // reverted to static.  But it could have
                // been turned on again by the
                // animCompleteDelegate.
                if (!animating)
                    curAnim = null;

                return false;
            }

            // Update mesh UVs:
            SetBleedCompensation();

            UpdateUVs();

            // Resize if selected:
            if (autoResize || pixelPerfect)
                CalcSize();

            return true;
        }*/
    /// <summary>
    /// Starts playing the specified animation
    /// Note: this doesn't resume from a pause,
    /// it completely restarts the animation. To
    /// unpause, use <see cref="UnpauseAnim"/>.
    /// </summary>
    /// <param name="anim">A reference to the animation to play.</param>
    public void PlayAnim(UVAnimation_Multi anim)
    {
        #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9
        if (deleted || !gameObject.activeInHierarchy)
        #else
        if (deleted || !gameObject.active)
        #endif
            return;
        if (!m_started)
            Start();

        curAnim = anim;
        curAnimIndex = curAnim.index;
        curAnim.Reset();

        // Ensure the framerate is not 0 so we don't
        // divide by zero:
        if (anim.framerate != 0.0f)
        {
            timeBetweenAnimFrames = 1f / anim.framerate;
        }
        else
        {
            timeBetweenAnimFrames = 1f; // Just some dummy value since it won't be used
        }

        timeSinceLastFrame = timeBetweenAnimFrames;

        // Only add to the animated list if
        // the animation has more than 1 frame
        // or the framerate is non-zero:
        if ((anim.GetFrameCount() > 1 || anim.onAnimEnd != UVAnimation.ANIM_END_ACTION.Do_Nothing) && anim.framerate != 0.0f)
        {
            StepAnim(0);
            // Start coroutine
            if (!animating)
            {
                //animating = true;
                AddToAnimatedList();
                //StartCoroutine(AnimationPump());
            }
        }
        else
        {
            // Make sure we are no longer in the animation pump:
            PauseAnim();

            // Since this is a single-frame anim,
            // call our delegate before setting
            // the frame so that our behavior is
            // consistent with multi-frame anims:
            if (animCompleteDelegate != null)
            {
                // See if we need to delay calling
                // our delegate to be consistent
                // with our framerate:
                if (anim.framerate != 0)
                {
                    Invoke("CallAnimCompleteDelegate", 1f / anim.framerate);
                }
                else
                    animCompleteDelegate(this);
            }

            StepAnim(0);
        }
    }
コード例 #7
0
ファイル: Sprite.cs プロジェクト: adahera222/Boats
    /// <summary>
    /// Like PlayAnim, but plays the animation in reverse.
    /// See <see cref="PlayAnim"/>.
    /// </summary>
    /// <param name="anim">Reference to the animation to play in reverse.</param>
    public void PlayAnimInReverse(UVAnimation_Multi anim)
    {
        curAnim = anim;
        curAnim.Reset();
        curAnim.PlayInReverse();

        // Ensure the framerate is not 0 so we don't
        // divide by zero:
        anim.framerate = Mathf.Max(0.0001f, anim.framerate);

        timeBetweenAnimFrames = 1f / anim.framerate;
        timeSinceLastFrame = timeBetweenAnimFrames;

        // Only add to the animated list if
        // the animation has more than 1 frame:
        if (anim.GetFrameCount() > 1)
        {
            StepAnim(0);
            // Start coroutine
            if (!animating)
            {
                //animating = true;
                AddToAnimatedList();
                //StartCoroutine(AnimationPump());
            }
        }
        else
        {
            // Since this is a single-frame anim,
            // call our delegate before setting
            // the frame so that our behavior is
            // consistent with multi-frame anims:
            if (animCompleteDelegate != null)
                animCompleteDelegate(this);

            StepAnim(0);
        }
    }