SuperSpriteAnim.AnimFinished C# (CSharp) Метод

AnimFinished() публичный Метод

public AnimFinished ( SpriteBase, sp ) : void
sp SpriteBase,
Результат void
	void AnimFinished(SpriteBase sp)
	{
		// See if we can't advance to the next animation:
		if ((curAnim + stepDir) >= spriteAnims.Length || (curAnim + stepDir) < 0)
		{
			// See if we need to loop (if we're reversing, we don't loop until we get back to the beginning):
			if (stepDir > 0 && pingPong)
			{
				stepDir = -1;	// Reverse direction of playback

				// Bounce back from the end:
				((AutoSpriteBase)sp).PlayAnimInReverse(spriteAnims[curAnim].anim, spriteAnims[curAnim].anim.GetFrameCount() - 2);
				return;

				// See if we need to tell our first animation
				// to loop us back again in anticipation of
				// another loop iteration:
				// 				if(loopCycles == -1 || numLoops < loopCycles)
				// 				{
				// 					spriteAnims[0].anim.loopReverse = true;
				// 				}

				// Proceed
			}
			else
			{
				// See if we can't loop:
				if (numLoops + 1 > loopCycles && loopCycles != -1)
				{
					isRunning = false;

					// Unset our delegate:
					sp.SetAnimCompleteDelegate(null);

					// Notify that we're ending:
					if (endDelegate != null)
						endDelegate(this);
					return;
				}
				else
				{
					// Loop the animation:
					++numLoops;

					if (pingPong)
					{
						// Bounce back from the first frame:
						spriteAnims[curAnim].sprite.PlayAnim(spriteAnims[curAnim].anim, 1);
						stepDir *= -1;
						return;
					}
					else
					{
						// Hide the current sprite
						HideSprite(sp, true);

						// Unset our delegate:
						sp.SetAnimCompleteDelegate(null);

						// Start back at the first animation:
						curAnim = 0;
					}
				}
			}
		}
		else
		{
			// Unset our delegate:
			sp.SetAnimCompleteDelegate(null);
			HideSprite(sp, true);
			curAnim += stepDir;
		}

		// Proceed to play the next animation:
		HideSprite(spriteAnims[curAnim].sprite, false);
		spriteAnims[curAnim].sprite.SetAnimCompleteDelegate(AnimFinished);
		if (stepDir > 0)
			spriteAnims[curAnim].Play();
		else
			spriteAnims[curAnim].PlayInReverse();
	}