[Tip] For anyone looking to animate the nebula using the entire spritesheet

The 61st sprite is the same as the first sprite, so you can discount it if you’re intending to loop through them all :slight_smile: (Otherwise it’ll look like the nebula is freezing for one frame)

2 Likes

For those wondering how to do it. I created a Vector2 variable called NebulaRectanglePosition to track the position of the current frame, being the first frame as NebulaRectanglePosition[0,0]. And adding 1 to the y position when x > 7. Here’s how I got it:

if (NebulaTimeSinceLastAnimationUpdate >= NebulaAnimationUpdateTime)

        {  

            NebulaRectanglePosition.x++;

            if (NebulaRectanglePosition.x > 7)

            {

                NebulaRectanglePosition.x = 0;

                NebulaRectanglePosition.y++;                                

            }

            if (NebulaRectanglePosition.y > 6 && NebulaRectanglePosition.x > 3)

            {

                NebulaRectanglePosition.y = 0;

                NebulaRectanglePosition.x = 0;

            }

            NebulaTimeSinceLastAnimationUpdate = 0;

            NebulaRectangle.x = NebulaRectanglePosition.x * NebulaRectangle.width;

            NebulaRectangle.y = NebulaRectanglePosition.y * NebulaRectangle.height;

        }

PS.: A little twik was needed since the last row has only 5 images.

Privacy & Terms