예제 #1
0
        public Animation(string[] files, SpriteObj animationOwner, float fps)
        {
            Loop      = true;
            IsPlaying = true;
            numFrames = files.Length;
            owner     = animationOwner;

            sprites = new Sprite[numFrames];

            for (int i = 0; i < sprites.Length; i++)
            {
                sprites[i] = new Sprite(files[i]);
            }

            owner.SetSprite(sprites[0]);

            if (fps > 0.0f)
            {
                frameDuration = 1 / fps;
            }
            else
            {
                frameDuration = 0.0f;
            }
        }
예제 #2
0
        public Animation(string[] files, float Fps, SpriteObj own, float frameDuration)
        {
            owner = own;



            nFiles = files.Length;

            frameDur = frameDuration;

            fps = Fps;


            sprites = new Sprite[nFiles];

            for (int i = 0; i < sprites.Length; i++)
            {
                sprites[i] = new Sprite(files[i]);
            }

            owner.SetSprite(sprites[0]);

            if (fps > 0.0f)
            {
                frameDur = 1 / fps;
            }

            else
            {
                frameDur = 0.0f;
            }
        }
예제 #3
0
 public void Update()
 {
     if (owner != null && isPlaying)
     {
         if (frameDur != 0.0f)
         {
             counter += GfxTools.Win.deltaTime;
             if (counter >= frameDur)
             {
                 counter      = 0;
                 currentFrame = (currentFrame + 1);
             }
         }
         else
         {
             owner.SetSprite(sprites[currentFrame]);
         }
     }
 }
예제 #4
0
        public void Update()
        {
            if (owner != null && IsPlaying)
            {
                if (frameDuration != 0.0f)
                {
                    counter += Game.DeltaTime;

                    if (counter >= frameDuration)
                    {
                        counter      = 0;
                        currentFrame = (currentFrame + 1);// % numFrames;
                    }
                }
                else
                {
                    owner.SetSprite(sprites[currentFrame]);
                }
            }
        }