コード例 #1
0
        public Animation(string[] files, SpriteObj animationOwner, float fps, bool loop = true)
        {
            Loop      = loop;
            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
ファイル: Animation2.cs プロジェクト: ngaeta/Lunar-Land
        public void Update()
        {
            fpsCounter -= GfxTools.Win.deltaTime;

            if (isPlaying && fpsCounter <= 0)
            {
                fpsCounter = 1 / fps;     //fps al secondo? cosa serve? 1/30 significa 30 animazioni in un secondo??? 1/2 fa due animazioni al secondo

                if (currentIndex >= sprites.Length)
                {
                    OnAnimationDeads();
                }

                owner.SetSprite(sprites[currentIndex++]);
            }
        }
コード例 #3
0
        public void Update()
        {
            if (owner != null && IsPlaying)
            {
                if (frameDuration != 0.0f)
                {
                    counter += GfxTools.Win.deltaTime;

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