void SetAnimationFrame(OTAnimation.Frame animationFrame)
    {
        if (spriteContainer != animationFrame.container || animationFrame.frameIndex != frameIndex)
        {
            if (passive)
            {
                spriteContainer = animationFrame.container;
                frameIndex      = animationFrame.frameIndex;
            }
            else
            {
                _spriteContainer = animationFrame.container;
                _frameIndex      = animationFrame.frameIndex;
            }

            if (onAnimationFrame != null)
            {
                onAnimationFrame(this);
            }
            if (!CallBack("onAnimationFrame", callBackParams))
            {
                CallBack("OnAnimationFrame", callBackParams);
            }

            isDirty = true;
        }
    }
Exemple #2
0
    void UpdateFrame()
    {
        if (frTime == 0 || frTime > frDurationDelta)
        {
            frTime = 0;
            // @note: I added modulo here to make it work...
            OTAnimation.Frame animationFrame = frames[((int)Mathf.Floor(time / frDurationDelta)) % frames.GetLength(0)];
            if (spriteContainer != animationFrame.container || animationFrame.frameIndex != frameIndex)
            {
                _spriteContainer = animationFrame.container;
                _frameIndex      = animationFrame.frameIndex;

                if (onAnimationFrame != null)
                {
                    onAnimationFrame(this);
                }
                if (!CallBack("onAnimationFrame", callBackParams))
                {
                    CallBack("OnAnimationFrame", callBackParams);
                }

                isDirty = true;
            }

            time += (Time.deltaTime * speed);
            if (endFrame != -1 && time >= endTime)
            {
                Stop();
                return;
            }
        }
        else
        {
            time += (Time.deltaTime * speed);
        }

        if (time >= frDuration)
        {
            if (looping)
            {
                time -= frDuration;
            }
            else
            {
                time = 0;
                timesPlayed++;
                if (timesPlayed >= numberOfPlays)
                {
                    Stop();
                }
            }
        }


        frTime += (Time.deltaTime * speed);
    }
Exemple #3
0
    void UpdateFrame(float deltaTime)
    {
        if (frames == null || frames.Length == 0)
        {
            return;
        }

        if (frTime == 0 || frTime >= frDurationDelta)
        {
            if (frTime >= frDurationDelta)
            {
                frTime -= frDurationDelta;
            }
            int idx = Mathf.FloorToInt(time / frDurationDelta);
            if (idx >= frames.Length)
            {
                idx = 0;
            }
            OTAnimation.Frame animationFrame = frames[idx];
            _animationFrameNumber = idx;
            SetAnimationFrame(animationFrame);
            time += (deltaTime * speed);
            if (endFrame != -1 && time >= endTime)
            {
                Stop();
                return;
            }
        }
        else
        {
            time += (deltaTime * speed);
        }

        if (time >= frDuration)
        {
            if (looping)
            {
                time -= frDuration;
            }
            else
            {
                time = 0;
                timesPlayed++;
                if (timesPlayed >= numberOfPlays)
                {
                    Stop();
                }
            }
        }
        frTime += (deltaTime * speed);
        // Debug.Log("frTime ="+frTime+", time = "+time);
    }
Exemple #4
0
    void UpdateFrame()
    {
        OTAnimation.Frame animationFrame = animation.GetFrame(time, direction, frameset);
        if (spriteContainer != animationFrame.container || animationFrame.frameIndex != frameIndex)
        {
            _spriteContainer = animationFrame.container;
            _frameIndex      = animationFrame.frameIndex;

            if (onAnimationFrame != null)
            {
                onAnimationFrame(this);
            }
            if (!CallBack("onAnimationFrame", callBackParams))
            {
                CallBack("OnAnimationFrame", callBackParams);
            }

            isDirty = true;
        }

        time += (Time.deltaTime * speed);
        if (endFrame != -1 && time > endTime)
        {
            Stop();
            return;
        }

        if (time > frDuration)
        {
            if (looping)
            {
                time -= frDuration;
            }
            else
            {
                time = 0;
                timesPlayed++;
                if (timesPlayed >= numberOfPlays)
                {
                    Stop();
                }
            }
        }
    }
    void UpdateFrame(float deltaTime)
    {
        if (frames == null || frames.Length == 0)
        {
            return;
        }

        if (frTime == 0 || frTime >= frDurationDelta)
        {
            if (frTime >= frDurationDelta)
            {
                frTime -= frDurationDelta;
            }
            int idx = Mathf.FloorToInt(time / frDurationDelta);
            if (idx >= frames.Length)
            {
                idx = 0;
            }
            OTAnimation.Frame animationFrame = frames[idx];
            if (spriteContainer != animationFrame.container || animationFrame.frameIndex != frameIndex)
            {
                if (passive)
                {
                    spriteContainer = animationFrame.container;
                    frameIndex      = animationFrame.frameIndex;
                }
                else
                {
                    _spriteContainer = animationFrame.container;
                    _frameIndex      = animationFrame.frameIndex;
                }

                if (onAnimationFrame != null)
                {
                    onAnimationFrame(this);
                }
                if (!CallBack("onAnimationFrame", callBackParams))
                {
                    CallBack("OnAnimationFrame", callBackParams);
                }

                isDirty = true;
            }

            time += (deltaTime * speed);
            if (endFrame != -1 && time >= endTime)
            {
                Stop();
                return;
            }
        }
        else
        {
            time += (deltaTime * speed);
        }

        if (time >= frDuration)
        {
            if (looping)
            {
                time -= frDuration;
            }
            else
            {
                time = 0;
                timesPlayed++;
                if (timesPlayed >= numberOfPlays)
                {
                    Stop();
                }
            }
        }
        frTime += (deltaTime * speed);
        // Debug.Log("frTime ="+frTime+", time = "+time);
    }